
Hi Ariel, --- Ariel Badichi <abadichi@bezeqint.net> wrote:
I experimented with the library for a few days now. Maybe I'm misusing it, but it seemed nice to have demuxer::run() thread(s) running before any (meaningful) asio operation is performed.
My solution was a demuxer::run() thread pool management class (using boost::thread_group to manage the threads themselves). The class has a timer that keeps queueing itself in its handler, unless the class's client requested it to stop. The stop operation also joins the thread(s).
There's a simpler way to do what you want. Just call demuxer.work_started() before calling demuxer.run(), and then call demuxer.work_finished() when you're ready to shut down. These functions are provided to ensure that demuxer.run() does not exit when an asynchronous operation (the "work") is being carried out by something external to the demuxer (such as a thread).
My instinct tells me that they shouldn't be merged: they are very different concepts, and I wouldn't like this specific abstraction eliminated in asio.
Fair enough. I'll leave them as separate for now. Cheers, Chris