Boost logo

Boost Users :

Subject: Re: [Boost-users] [asio] posting a function to an io_service object
From: Casimiro, Daniel C CIV NUWC NWPT (daniel.casimiro_at_[hidden])
Date: 2009-12-29 07:58:10


 

> -----Original Message-----
>
> You are right, not polling the io_services from the main
> thread makes the f() calls run in the other threads as
> intended. In that case is there a way to check from the main
> thread if the io_services finished executing the posted
> handlers (some kind of a peek())?

The run command will return if you get rid of the two work objects. Then, you could just wait for the threads to join.

> I have a program where there are several parallel io_threads
> and I want to run two distinct library functions in each
> io_service first thing an io_service is started and last
> thing before an io_service is stopped. These functions are
> posted from the main thread. My problem is with the function
> that is to be executed last: how can I wait for that to be
> executed before stopping the io_service and joining the
> thread? Calling poll()/dispatch() from the main thread is not
> an option, it seems.

Look into writing a custom service object. I think that the logging example is a good place to start. There is an entry point that gets called when the io_service is being stopped.

~Dan




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