Boost Users :
Subject: Re: [Boost-users] boost - asio - advise
From: Igor R (boost.lists_at_[hidden])
Date: 2009-05-09 17:54:10
> I've looked through the examples and there is a lot of different potential choices
> to make and was looking to see if anyone could advise on an arrangement that
> would allow for using multiple threads but block as little as possible.
Lets assume you want to send data from the main thread, while your
io_service is running in another thread. You can't access the socket
object in a straightforward way from the main thread without potential
race-condition, because it's being processed by io_service in another
thread. What you can do instead is to bind the data to a functor and
post it to io_service's thread (look at the io_service::post() method
for details) - this way you don't need to explicitly lock anything.
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net