本文整理汇总了C++中rc::Handle::add方法的典型用法代码示例。如果您正苦于以下问题:C++ Handle::add方法的具体用法?C++ Handle::add怎么用?C++ Handle::add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rc::Handle
的用法示例。
在下文中一共展示了Handle::add方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: executeOneTaskIfPossible_CRITICAL_SECTION
void ThreadPool::executeOneTaskIfPossible_CRITICAL_SECTION()
{
if ( m_tasks.empty() && m_idleTasks.empty() && (!m_isMainThread.get() || m_mainThreadTasks.empty()) )
m_stateCond.wait( m_stateMutex );
else
{
std::vector<Task *> *taskQueue;
if ( m_isMainThread.get() && !m_mainThreadTasks.empty() )
taskQueue = &m_mainThreadTasks;
else if ( !m_tasks.empty() )
taskQueue = &m_tasks;
else taskQueue = &m_idleTasks;
Task *task = taskQueue->back();
size_t index;
bool keep;
task->preExecute_CRITICAL_SECTION( index, keep );
if ( !keep )
taskQueue->pop_back();
m_stateMutex.release();
try
{
task->execute( index );
}
catch ( Exception e )
{
Util::SimpleString prefixedException = "Exception: " + e.getDesc();
RC::Handle<LogCollector> logCollector = task->getLogCollector();
if ( logCollector )
logCollector->add( prefixedException.data(), prefixedException.length() );
}
catch ( ... )
{
static Util::SimpleString const genericException = "Exception (unknown)";
RC::Handle<LogCollector> logCollector = task->getLogCollector();
if ( logCollector )
logCollector->add( genericException.data(), genericException.length() );
}
m_stateMutex.acquire();
task->postExecute_CRITICAL_SECTION();
if ( task->completed_CRITICAL_SECTION() )
{
void (*finishedCallback)( void * ) = task->getFinishedCallback();
if ( finishedCallback )
finishedCallback( task->getFinishedUserdata() );
task->dispose();
// [pzion 20101108] Must wake waiter because they might be
// waiting on the task completion
m_stateCond.broadcast();
}
}
}