Esempio n. 1
0
 /** Wait for worker threads to exit */
 void WaitExit()
 {
     boost::unique_lock<boost::mutex> lock(cs);
     while (numThreads > 0){
         cond.wait(lock);
     }
 }
Esempio n. 2
0
 /** Enqueue a work item */
 bool Enqueue(WorkItem* item)
 {
     boost::unique_lock<boost::mutex> lock(cs);
     if (queue.size() >= maxDepth) {
         return false;
     }
     queue.push_back(item);
     cond.notify_one();
     return true;
 }
Esempio n. 3
0
 /** Enqueue a work item */
 bool Enqueue(WorkItem* item)
 {
     boost::unique_lock<boost::mutex> lock(cs);
     if (queue.size() >= maxDepth) {
         return false;
     }
     queue.emplace_back(std::unique_ptr<WorkItem>(item));
     cond.notify_one();
     return true;
 }
Esempio n. 4
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)();
     }
 }
Esempio n. 5
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;
     }
 }
Esempio n. 6
0
 /** Interrupt and exit loops */
 void Interrupt()
 {
     boost::unique_lock<boost::mutex> lock(cs);
     running = false;
     cond.notify_all();
 }