c++ – integration of windows message loop (PeekMessage -> DispatchMessage) with boost.asio
I have a Windows application that uses boost.asio for I/O.
but the asio’s io_context::run() executes in a separate thread, because of WinMain() function has while() {} loop with PeekMessage() and DispatchMessage() functions.
pseudocode:
int WinMain(...) {
asio::io_context ios;
std::thread thread{[&ios](){ ios.run(); }};
MSG msg;
while ( ::PeekMessage(&msg, ...) ) {
switch ( msg.message ) {
...
}
::DispatchMessage(&msg);
}
}
my goal is to get rid of the extra thread.
so, my question is: how can I integrate windows message loop into asio event loop?
Read more here: Source link
