thanks for your reply where can i find the duration of sleep that basic_thread_pool does then wakes up???it sleeps till some methods like submit are called.i thought submit just make tasks without starting the thread and async is the one which launch thread but i was totally wrong drived by asio paradigm what is the reason of wake up??is it timed internally or it needs explicit launching?we can do both using schedulers although i do not know how also why async leads to pausing test_executor_adaptor???here async return is assigned to variable t2 so it will not block in async destructor,but will work asynchronously till the scope is ended and then block in destructor of async???this i do not know answer to it????why async pause ??? what do you mean by sleeping?you meant to sleep between submit calls so they are finished thanks again you helped me in 3 years misunderstood behavior On Wed, Mar 4, 2020 at 8:25 AM Gavin Lambert via Boost < boost@lists.boost.org> wrote:
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.
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost