
Atry wrote:
Yuval Ronen 写道:
Here are a few classes which I think are very useful:
1. A thread_pool class. I think there's not much I can tell you that you don't know about it. It's something that has threads, and can accept tasks to be pushed into a queue, and executed in turn when a thread is available. It can also be suspended (stop handling tasks, but keep the threads alive) and resumed.
2. Two 'dispatcher' classes, one for plain threads, and one for thread_pools. They accept a single task, or several tasks, to be executed, either by dedicated threads (the thread_dispatcher class), or by a thread_pool (the thread_pool_dispatcher class). These classes provide a wait() method that block until all tasks are done.
We already have thread pool and dispatcher in Boost.Asio, although it is a very simple one.
Oh, I didn't know that. Thanks for the pointer! Do they provide the same functionality (in general, not up to the last feature)? I will take a look at them. IMO, if they are like mine, they should reside in Boost.Thread rather than in Asio.