本文整理汇总了C++中OutputMessagePool::startExecutionFrame方法的典型用法代码示例。如果您正苦于以下问题:C++ OutputMessagePool::startExecutionFrame方法的具体用法?C++ OutputMessagePool::startExecutionFrame怎么用?C++ OutputMessagePool::startExecutionFrame使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OutputMessagePool
的用法示例。
在下文中一共展示了OutputMessagePool::startExecutionFrame方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
}
示例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
}
示例3: 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;
}
}
}
示例4: 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();
}
}
}