当前位置: 首页>>代码示例>>C++>>正文


C++ OutputMessagePool::sendAll方法代码示例

本文整理汇总了C++中OutputMessagePool::sendAll方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessagePool::sendAll方法的具体用法?C++ OutputMessagePool::sendAll怎么用?C++ OutputMessagePool::sendAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在OutputMessagePool的用法示例。


在下文中一共展示了OutputMessagePool::sendAll方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: dispatcherThread

OTSYS_THREAD_RETURN Dispatcher::dispatcherThread(void* p)
{
	#if defined __EXCEPTION_TRACER__
	ExceptionHandler dispatcherExceptionHandler;
	dispatcherExceptionHandler.InstallHandler();
	#endif
	srand((uint32_t)OTSYS_TIME());

	OutputMessagePool* outputPool = NULL;
	while(Dispatcher::m_threadState != Dispatcher::STATE_TERMINATED)
	{
		Task* task = NULL;
		// check if there are tasks waiting
		OTSYS_THREAD_LOCK(getDispatcher().m_taskLock, "");
		if(getDispatcher().m_taskList.empty()) //if the list is empty wait for signal
			OTSYS_THREAD_WAITSIGNAL(getDispatcher().m_taskSignal, getDispatcher().m_taskLock);

		if(!getDispatcher().m_taskList.empty() && Dispatcher::m_threadState != Dispatcher::STATE_TERMINATED)
		{
			// take the first task
			task = getDispatcher().m_taskList.front();
			getDispatcher().m_taskList.pop_front();
		}

		OTSYS_THREAD_UNLOCK(getDispatcher().m_taskLock, "");
		// finally execute the task...
		if(!task)
			continue;

		if(!task->hasExpired())
		{
			if((outputPool = OutputMessagePool::getInstance()))
				outputPool->startExecutionFrame();

			(*task)();
			if(outputPool)
				outputPool->sendAll();

			g_game.clearSpectatorCache();
		}

		delete task;
	}

	#if defined __EXCEPTION_TRACER__
	dispatcherExceptionHandler.RemoveHandler();
	#endif
	#if not defined(WIN32)
	return NULL;
	#endif
}
开发者ID:Fir3element,项目名称:035,代码行数:51,代码来源:tasks.cpp

示例2: dispatcherThread

void Dispatcher::dispatcherThread(void* p)
{
	Dispatcher* dispatcher = (Dispatcher*)p;
	#if defined __EXCEPTION_TRACER__
	ExceptionHandler dispatcherExceptionHandler;
	dispatcherExceptionHandler.InstallHandler();
	#endif
	srand((uint32_t)OTSYS_TIME());

	OutputMessagePool* outputPool = NULL;
	boost::unique_lock<boost::mutex> taskLockUnique(dispatcher->m_taskLock, boost::defer_lock);
	while(Dispatcher::m_threadState != Dispatcher::STATE_TERMINATED)
	{
		Task* task = NULL;
		// check if there are tasks waiting
		taskLockUnique.lock();
		if(dispatcher->m_taskList.empty()) //if the list is empty wait for signal
			dispatcher->m_taskSignal.wait(taskLockUnique);

		if(!dispatcher->m_taskList.empty() && Dispatcher::m_threadState != Dispatcher::STATE_TERMINATED)
		{
			// take the first task
			task = dispatcher->m_taskList.front();
			dispatcher->m_taskList.pop_front();
		}

		taskLockUnique.unlock();
		// finally execute the task...
		if(!task)
			continue;

		if(!task->hasExpired())
		{
			if((outputPool = OutputMessagePool::getInstance()))
				outputPool->startExecutionFrame();

			(*task)();
			if(outputPool)
				outputPool->sendAll();

			g_game.clearSpectatorCache();
		}

		delete task;
	}

	#if defined __EXCEPTION_TRACER__
	dispatcherExceptionHandler.RemoveHandler();
	#endif
}
开发者ID:A-Syntax,项目名称:cryingdamson-0.3.6-8.60-V8.2,代码行数:50,代码来源:tasks.cpp

示例3: flush

void Dispatcher::flush()
{
    while (!m_taskList.empty()) {
        Task* task = m_taskList.front();
        m_taskList.pop_front();
        (*task)();
        delete task;

        OutputMessagePool* outputPool = OutputMessagePool::getInstance();
        if (outputPool) {
            outputPool->sendAll();
        }

        g_game.clearSpectatorCache();
    }
}
开发者ID:EnzzoCaaue,项目名称:forgottenserver,代码行数:16,代码来源:tasks.cpp

示例4: flush

void Dispatcher::flush()
{
	Task* task = NULL;
	while(!m_taskList.empty()){
		task = m_taskList.front();
		m_taskList.pop_front();
		(*task)();
		delete task;
		OutputMessagePool* outputPool = OutputMessagePool::getInstance();
		if(outputPool)
			outputPool->sendAll();
		g_game.clearSpectatorCache();
	}
	#ifdef __DEBUG_SCHEDULER__
	std::cout << "Flushing Dispatcher" << std::endl;
	#endif
}
开发者ID:HeavenIsLost,项目名称:server,代码行数:17,代码来源:tasks.cpp

示例5: dispatcherThread

void Dispatcher::dispatcherThread()
{
    OutputMessagePool* outputPool = OutputMessagePool::getInstance();

    // NOTE: second argument defer_lock is to prevent from immediate locking
    std::unique_lock<std::mutex> taskLockUnique(m_taskLock, std::defer_lock);

    while (m_threadState != STATE_TERMINATED) {
        Task* task = nullptr;

        // check if there are tasks waiting
        taskLockUnique.lock();

        if (m_taskList.empty()) {
            //if the list is empty wait for signal
            m_taskSignal.wait(taskLockUnique);
        }

        if (!m_taskList.empty() && (m_threadState != STATE_TERMINATED)) {
            // take the first task
            task = m_taskList.front();
            m_taskList.pop_front();
        }

        taskLockUnique.unlock();

        // finally execute the task...
        if (task) {
            if (!task->hasExpired()) {
                outputPool->startExecutionFrame();
                (*task)();
                outputPool->sendAll();

                g_game.clearSpectatorCache();
            }

            delete task;
        }
    }
}
开发者ID:EnzzoCaaue,项目名称:forgottenserver,代码行数:40,代码来源:tasks.cpp

示例6: dispatcherThread

void Dispatcher::dispatcherThread()
{
	OutputMessagePool* outputPool = OutputMessagePool::getInstance();

	// NOTE: second argument defer_lock is to prevent from immediate locking
	std::unique_lock<std::mutex> taskLockUnique(taskLock, std::defer_lock);

	while (getState() != THREAD_STATE_TERMINATED) {
		// check if there are tasks waiting
		taskLockUnique.lock();

		if (taskList.empty()) {
			//if the list is empty wait for signal
			taskSignal.wait(taskLockUnique);
		}

		if (!taskList.empty()) {
			// take the first task
			Task* task = taskList.front();
			taskList.pop_front();
			taskLockUnique.unlock();

			if (!task->hasExpired()) {
				// execute it
				outputPool->startExecutionFrame();
				(*task)();
				outputPool->sendAll();

				g_game.map.clearSpectatorCache();
			}
			delete task;
		} else {
			taskLockUnique.unlock();
		}
	}
}
开发者ID:comedinha,项目名称:New-Poke-Lite,代码行数:36,代码来源:tasks.cpp

示例7: dispatcherThread

void Dispatcher::dispatcherThread(void* p)
{
	#if defined __EXCEPTION_TRACER__
	ExceptionHandler dispatcherExceptionHandler;
	dispatcherExceptionHandler.InstallHandler();
	#endif
	srand((unsigned int)OTSYS_TIME());
	#ifdef __DEBUG_SCHEDULER__
	std::cout << "Starting Dispatcher" << std::endl;
	#endif

	OutputMessagePool* outputPool;

	// NOTE: second argument defer_lock is to prevent from immediate locking
	boost::unique_lock<boost::mutex> taskLockUnique(getDispatcher().m_taskLock, boost::defer_lock);

	while(Dispatcher::m_threadState != Dispatcher::STATE_TERMINATED){
		Task* task = NULL;

		// check if there are tasks waiting
		taskLockUnique.lock();//getDispatcher().m_taskLock.lock();

		if(getDispatcher().m_taskList.empty()){
			//if the list is empty wait for signal
			#ifdef __DEBUG_SCHEDULER__
			std::cout << "Dispatcher: Waiting for task" << std::endl;
			#endif
			getDispatcher().m_taskSignal.wait(taskLockUnique);
		}

		#ifdef __DEBUG_SCHEDULER__
		std::cout << "Dispatcher: Signalled" << std::endl;
		#endif

		if(!getDispatcher().m_taskList.empty() && (Dispatcher::m_threadState != Dispatcher::STATE_TERMINATED)){
			// take the first task
			task = getDispatcher().m_taskList.front();
			getDispatcher().m_taskList.pop_front();
		}

		taskLockUnique.unlock();

		// finally execute the task...
		if(task){
			OutputMessagePool::getInstance()->startExecutionFrame();
			(*task)();
			delete task;
			
			outputPool = OutputMessagePool::getInstance();
			if(outputPool){
				outputPool->sendAll();
			}

			g_game.clearSpectatorCache();
			#ifdef __DEBUG_SCHEDULER__
			std::cout << "Dispatcher: Executing task" << std::endl;
			#endif
		}
	}
#if defined __EXCEPTION_TRACER__
	dispatcherExceptionHandler.RemoveHandler();
#endif
}
开发者ID:Codex-NG,项目名称:avesta74,代码行数:63,代码来源:tasks.cpp

示例8: dispatcherThread

void Dispatcher::dispatcherThread(void* p)
{
	Dispatcher* dispatcher = static_cast<Dispatcher*>(p);
	ExceptionHandler dispatcherExceptionHandler;
	dispatcherExceptionHandler.InstallHandler();
#ifdef __DEBUG_SCHEDULER__
	std::cout << "Starting Dispatcher" << std::endl;
#endif
	OutputMessagePool* outputPool;
	// NOTE: second argument defer_lock is to prevent from immediate locking
	boost::unique_lock<boost::mutex> taskLockUnique(dispatcher->m_taskLock, boost::defer_lock);

	while (dispatcher->m_threadState != STATE_TERMINATED)
	{
		Task* task = NULL;
		// check if there are tasks waiting
		taskLockUnique.lock();

		if (dispatcher->m_taskList.empty())
		{
			//if the list is empty wait for signal
#ifdef __DEBUG_SCHEDULER__
			std::cout << "Dispatcher: Waiting for task" << std::endl;
#endif
			dispatcher->m_taskSignal.wait(taskLockUnique);
		}

#ifdef __DEBUG_SCHEDULER__
		std::cout << "Dispatcher: Signalled" << std::endl;
#endif

		if (!dispatcher->m_taskList.empty() && (dispatcher->m_threadState != STATE_TERMINATED))
		{
			// take the first task
			task = dispatcher->m_taskList.front();
			dispatcher->m_taskList.pop_front();
		}

		taskLockUnique.unlock();

		// finally execute the task...
		if (task)
		{
			if (!task->hasExpired())
			{
				OutputMessagePool::getInstance()->startExecutionFrame();
				(*task)();
				outputPool = OutputMessagePool::getInstance();

				if (outputPool)
				{
					outputPool->sendAll();
				}

				g_game.clearSpectatorCache();
			}

			delete task;
#ifdef __DEBUG_SCHEDULER__
			std::cout << "Dispatcher: Executing task" << std::endl;
#endif
		}
	}

	dispatcherExceptionHandler.RemoveHandler();
}
开发者ID:edubart,项目名称:otserv,代码行数:66,代码来源:tasks.cpp


注:本文中的OutputMessagePool::sendAll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。