progschj / ThreadPool

A simple C++11 Thread Pool implementation
zlib License
7.64k stars 2.21k forks source link

Wait for all workers to be done #14

Closed IngwiePhoenix closed 10 years ago

IngwiePhoenix commented 10 years ago

Is there a way to do that? I can only see the method to add a function to the queue. But I can not see a function to wait for when all threads are done working.

In my scenario, it will be that the main application sends a number of tasks to the queue and in the meantime processes and prepares new tasks to be put into the list. However, if all tasks are processed and handed to the queue, how do I wait for all tasks to be done?

progschj commented 10 years ago

You can wait on the futures the enqueue method returns.