Boost logo

Boost Users :

From: Jose Martinez (jmartine_1026_at_[hidden])
Date: 2008-05-23 21:40:10


Hello,

I have setup a multithreaded application with multiple io_service objects because I want to pick out the thread that executes a particular event handler. So each thread object will have a copy of their own io_service object. The main server object (who handles accepts) picks which thread executes an event handler. I hope that makes sense.

Anyways the main run function of the thread object will have to call io_service.run() so that it can execute the event handlers that the server object sets up for it. My question is how do I keep the thread's io_service.run() from returning right away, since there will be no work for the io_service.run() to do until the server lines up a new connection for the thread to handle?

I came up with ways to do this using deadline_timer_service.async_wait(), where the thread calls async_wait() and the event handler for the async_wait() just calls another async_wait(). This should keep work for the io_service.run() to do and permanently blocked but I find this approach quite hackish. But for all I know this could be why deadline_timer_service was created for.

Any thoughts on a more elegant way of doing this?

 
thanks
jose
"survival first, then happiness as we can manage it"

      


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