예제 #1
0
파일: tasks.cpp 프로젝트: cp1337/devland
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);
	}
}
예제 #2
0
파일: tasks.cpp 프로젝트: Fir3element/035
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);
}