I have a thread pool which execute tasks asynchronously. But I need to wait for a certain task to complete before proceeding (running the task in current thread is not allowed, the task must be run by a worker thread).
What's the easiest way to achieve this 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 is complete???
Aucun commentaire:
Enregistrer un commentaire