[asio] intergrate with message loop how to
on platform windows, asio is using IOCP. and IOCP handel got signaled when there is pending events thus we can use MsgWaitForMultipleObjectsEx to wait on both the message queue and the IOCP. when we get a message, call PeekMessage and then DispatchMessage just like the mornal message loop. when we get IOCP singaled, call boost::asio::io_service::pull_one() and we processed the IO events ! by this way, we can have a thread that does both GUI and IO. that's very handy for non-performance critical applications. but, we can't access to the IOCP HANDLE used by asio. that's said. very said. on platform Linux, asio is using epoll. we can get X11 socket, and use asio to monitor that socket, and again calls X11 functions when the socket gets ready. thus, we can intergrate X11 message loop with asio, that's fine. if we are using gtk, it is more convinent to have epoll fd monitored by glib first, and then goes to run asio::io_service::pull_one(). again, that required access to epoll fd used by asio. if asio can expose these internal HANDLE or fd , that'll going to be more powefull !
On May 4, 2014, at 2:46 PM, microcai
but, we can't access to the IOCP HANDLE used by asio. that's said. very said.
...
again, that required access to epoll fd used by asio.
if asio can expose these internal HANDLE or fd , that'll going to be more powefull !
I'm not excited about exposing a normally rightfully private value of a platform-dependent type - that would require platform-dependent code to use properly anyway. Perhaps you might propose a cross-platform asio API extension that could give you control at the times you want, using the completion-handler mechanism?
participants (2)
-
microcai
-
Nat Goodspeed