Wait for tasks to get completed in threadpool.
- by Alien01
Hello
I have created a thread pool in C++ which stores all tasks in a queue. Thread pool start n number of threads which takes tasks from queue , process each task and then delete tasks from queue.
Now , I want to wait till all tasks get completed. Checking for empty queue for completion of tasks may not work as , task can be given to each thread and queue can be emptied but still the tasks can in processing mode.
I am not getting idea how to wait for all the tasks completion.This is a design problem. Any suggestions?