Giving some work to the I/O service
Now, it is time for us to give some work to the io_service
object. Knowing more about boost::bind
and boost::mutex
will help us to give the io_service
object work to do. There are two member functions in the io_service
object: the post()
and dispatch()
functions, which we will frequently use to do this. The post()
function is used to request the io_service
object to run the io_service
object's work after we queue up all the work, so it does not allow us to run the work immediately. While the dispatch()
function is also used to make a request to the io_service
object to run the io_service
object's work, but it will execute the work right away without queuing it up.
Using the post() function
Let's examine the
Get Boost.Asio C++ Network Programming - Second Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.