void Dispatcher::addTask(Task* task) { OTSYS_THREAD_LOCK(m_taskLock, ""); bool do_signal = false; if(!Dispatcher::m_shutdown){ do_signal = m_taskList.empty(); m_taskList.push_back(task); } #ifdef _DEBUG else{ std::cout << "Error: [Dispatcher::addTask] Dispatcher thread is terminated." << std::endl; } #endif OTSYS_THREAD_UNLOCK(m_taskLock, ""); // send a signal if the list was empty if(do_signal){ OTSYS_THREAD_SIGNAL_SEND(m_taskSignal); } }
void Dispatcher::addTask(Task* task, bool front/* = false*/) { bool signal = false; if(Dispatcher::m_threadState == Dispatcher::STATE_RUNNING) { OTSYS_THREAD_LOCK(m_taskLock, ""); signal = m_taskList.empty(); if(front) m_taskList.push_front(task); else m_taskList.push_back(task); OTSYS_THREAD_UNLOCK(m_taskLock, ""); } #ifdef __DEBUG_SCHEDULER__ else std::cout << "[Error - Dispatcher::addTask] Dispatcher thread is terminated." << std::endl; #endif // send a signal if the list was empty if(signal) OTSYS_THREAD_SIGNAL_SEND(m_taskSignal); }