Boost logo

Boost :

From: Gavin Lambert (boost_at_[hidden])
Date: 2020-03-04 06:25:11

On 29/02/2020 23:22, Adham Sabry wrote:
> i am trying to learn executors and executors thread pools using with
> boost::async
> but i found strange behabiour
> when i make thread pool adaptor ea and submit tasks to it and make ea00 and
> submit tasks to it
> if i started ea with async , it automatically starts ea00
> the attached file has the code
> i thought that async will only start the passed thread pool"adaptor"
> But i think there is underlying thing which gather all threads of different
> pools into single entity and starts them with any call to boost::async
> is this a bug???
> i run this from windows 7 64 by visual studio 2017

Perhaps I'm missing something, since I haven't played with Boost
executors before. But this looks entirely normal to me.

Creating a basic_thread_pool will presumably start some background
threads that are sleeping on work.

When you submit_some(ea00) it queues some work on ea00 that will execute
at some unspecified later time (but typically relatively soon), whenever
one of the sleeping threads in ea00 wakes up.

Your use of boost::async(ea, &f1) is entirely unrelated to this --
except that it causes the test_executor_adaptor() thread to pause long
enough that you're not destroying the ea00 thread pool before it gets
around to executing the work.

You can see this by commenting out the boost::async and just sleeping
instead; the submitted work gets called in the background.

There is no "gathering from multiple pools into a single entity". Each
thread pool is entirely separate at all times.

Boost list run by bdawes at, gregod at, cpdaniel at, john at