// Check if a Lock taken on the common mutex succeeded, wait up to 55s more in congestion static bool checkRetry(Lock& lock) { if (lock.locked()) return true; Engine::setCongestion("Call endpoint mutex busy"); bool ok = lock.acquire(s_mutex,55000000); Engine::setCongestion(); return ok; }
void WorkerThread::run () { // // Signal that the thread has started executing // _data->threadSemaphore.post(); while (true) { // // Wait for a task to become available // _data->taskSemaphore.wait(); { Lock taskLock (_data->taskMutex); // // If there is a task pending, pop off the next task in the FIFO // if (_data->numTasks > 0) { Task* task = _data->tasks.front(); TaskGroup* taskGroup = task->group(); _data->tasks.pop_front(); _data->numTasks--; taskLock.release(); task->execute(); taskLock.acquire(); delete task; taskGroup->_data->removeTask(); } else if (_data->stopped()) { break; } } } }