70#if SAWYER_MULTI_THREADED
72 boost::condition_variable cond;
73 size_t nActiveWorkers = 0;
76 maxWorkers = boost::thread::hardware_concurrency();
77 ASSERT_require(maxWorkers > 0);
81 boost::unique_lock<boost::mutex> lock(mutex);
82 while (!workList.isEmpty() && nActiveWorkers >= maxWorkers)
86 while (!workList.isEmpty() && nActiveWorkers < maxWorkers) {
89 static void doWork(Functor f,
const typename WorkItems::Item &item, WorkItems *workList,
90 boost::mutex *mutex, boost::condition_variable *cond,
size_t *nActiveWorkers) {
92 boost::lock_guard<boost::mutex> lock(*mutex);
98 boost::thread thrd(Worker::doWork, f, workList.next(), &workList, &mutex, &cond, &nActiveWorkers);
104 if (workList.isEmpty() && 0 == nActiveWorkers)
108 while (!workList.isEmpty())
109 f(workList.next(), workList);