Beispiel #1
0
 /** Wait for worker threads to exit */
 void WaitExit()
 {
     boost::unique_lock<boost::mutex> lock(cs);
     while (numThreads > 0){
         cond.wait(lock);
     }
 }
Beispiel #2
0
 /** Thread function */
 void Run()
 {
     ThreadCounter count(*this);
     while (running) {
         std::unique_ptr<WorkItem> i;
         {
             boost::unique_lock<boost::mutex> lock(cs);
             while (running && queue.empty())
                 cond.wait(lock);
             if (!running)
                 break;
             i = std::move(queue.front());
             queue.pop_front();
         }
         (*i)();
     }
 }
Beispiel #3
0
 /** Thread function */
 void Run()
 {
     ThreadCounter count(*this);
     while (running) {
         WorkItem* i = 0;
         {
             boost::unique_lock<boost::mutex> lock(cs);
             while (running && queue.empty())
                 cond.wait(lock);
             if (!running)
                 break;
             i = queue.front();
             queue.pop_front();
         }
         (*i)();
         delete i;
     }
 }