Boost logo

Boost :

Subject: [boost] [asio] intergrate with message loop how to
From: microcai (microcai_at_[hidden])
Date: 2014-05-04 14:46:44


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 !


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk