Esempio n. 1
0
 void AsyncTaskExecutor::run()
 {
     while(_isRunning)
     {
         std::unique_lock<std::mutex> lock(_mutex);
         if(!_queue.empty())
         {
             Runnable *task = _queue.front();
             _queue.pop_front();
             if(task!=NULL)
             {
                 _isBusy = true;
                 _currentTask = task;
                 lock.unlock();
                 task->run();
                 lock.lock();
                 _currentTask = NULL;
                 if(task->toDelete())
                     delete task;
             }
         }
         else if(_isRunning)
         {
             _isBusy = false;
             _signal.wait(lock);
         }
     }
     return;
 }
Esempio n. 2
0
 void TaskExecutor::clearAll()
 {
     std::lock_guard<std::mutex> lock(_mutex);
     for(int i = 0; i < _queue.size(); i++)
     {
         Runnable *task = _queue[i];
         if(task && task->toDelete())
             delete task;
     }
     _queue.clear();
 }
Esempio n. 3
0
 void TaskExecutor::executeAll()
 {
     std::lock_guard<std::mutex> lock(_mutex);
     while(!_queue.empty())
     {
         Runnable *task = _queue.front();
         _queue.pop_front();
         if(task!=NULL)
         {
             task->run();
             if(task->toDelete())
                 delete task;
         }
     }
 }