$include_dir="/home/hyper-archives/boost/include"; include("$include_dir/msg-header.inc") ?>
Subject: Re: [boost] a thread pool that allows recursive calls
From: Gavin Lambert (gavinl_at_[hidden])
Date: 2015-06-11 19:11:25
On 12/06/2015 07:53, Frédéric Bron wrote:
> I need to perform some tasks in parallel and want to control the
> number of CPUs that are used.
> A threadpool seems to be what I want and
> http://threadpool.sourceforge.net/ looks good.
>
> However, my tasks may also want to launch some parallel sub-tasks and
> the sub-tasks may also want to launch tome parallel sub-sub-tasks...
> and this is not possible with this implementation of threadpool. I
> have programmed something that works and I wonder if anyone had also
> already done that because my implementation is very rudimental for now
> and if something already exists I do not want to reinvent the wheel.
Boost.ASIO's io_service provides an excellent threadpool. It's a little
mutex-happy but most applications won't care about that.
Subtasks can simply be posted to the io_service and they will complete
asynchronously on the same thread or any other in the threadpool.
You can use callbacks, futures, or coroutines to collect the results of
the subtasks.