C++ (Qt)// workervoid MyTask::operator()( void ){ .... if (--MyTask::taskCount <= 0) { std::unique_lock.. MyTask::cond.notify_one(); }} // main threadMyTask::taskCount = tasks.size();for (int i = 0; i < tasks.size(); ++i pool.submit(tasks[i]); while (MyTask::taskCount) { std::unique_lock.. MyTask::cond.wait(lock);}
C++ (Qt) /** * \b Effects: close the \c basic_thread_pool for submissions. * The worker threads will work until there is no more closures to run. */ void close() { work_queue.close(); }