multithreading - C++ / boost : how to signal async task completion? -


i have thread pool executes tasks asynchronously. need wait task complete before proceeding (running task in current thread not allowed, task must run worker thread).

what's easiest way achieve using c++11 or boost?

  pool.enqueue([]() {     std::this_thread::sleep_for(2s); // task 1     // notify task 1 completion???     std::this_thread::sleep_for(2s); // task 2   });   // wait until task 1 complete??? 

if have thread pool, either pool should handle dependencies or should chain continuation task first task directly.

otherwise, pool can deadlock. imagine example pool 1 thread. block indefinitely. same can occur many threads given enough task inter dependencies.


Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -