本文整理汇总了C++中Task::Execute方法的典型用法代码示例。如果您正苦于以下问题:C++ Task::Execute方法的具体用法?C++ Task::Execute怎么用?C++ Task::Execute使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Task
的用法示例。
在下文中一共展示了Task::Execute方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteTaskGroups
void TaskProxy::ExecuteTaskGroups( bool _bUseCallerThread, TaskGroup* _aGroup, const uint32 _cnGroup )
{
const Array<WorkerThread*>& rvpThreadPool = WorkerThreadManager::s_GetInstance()->_GetPool();
uint32 i, j, nThread = rvpThreadPool.size();
// Define proxy for threads
for( i = 0; i < nThread; i++ )
rvpThreadPool[i]->SetTaskProxy( this );
for( j = 0; j < _cnGroup; j++ )
{
const Array<Task*>& rvpTask = _aGroup[j].m_vpTask;
uint32 k, nTask = rvpTask.size();
for( k = 0; k < nTask; k++ )
PushTask( rvpTask[k] );
// Signal threads
for( i = 0; i < nThread; i++ )
rvpThreadPool[i]->ForceBusy();
uint32 iFinishedTask = 0;
if( _bUseCallerThread )
{
Task* pTask = NULL;
while( (pTask = PopTask()) != NULL )
{
pTask->Execute();
iFinishedTask++;
}
}
// Wait other threads completion
while( iFinishedTask != nTask )
{
for( i = 0; i < nThread; i++ )
{
if( rvpThreadPool[i]->PopFinishedTask() )
iFinishedTask++;
}
}
}
// [Remove proxy once finished
for( i = 0; i < nThread; i++ )
rvpThreadPool[i]->SetTaskProxy( NULL );
}
示例2: Run
void RenderingTaskWorkerRoutine::Run(const INT64 timeslice)
{
SystemTimer& clientTimer = GooRoomVirtualClient::Instance().GetClientTimer();
const ServerTime startTime = clientTimer.Check();
const milliseconds timeSliceMil = milliseconds(timeslice);
ServerTime availableTimeSlice = timeSliceMil - (clientTimer.Check()-startTime);
// CFConnectionList& cfConnectionList = GooRoomVirtualClient::Instance().GetTemporaryCFConnectionList();
// for(int i = 0; i < cfConnectionList.size(); ++i)
// {
// CFConnectionPointer connection = cfConnectionList[i];
//
// if(connection->CanBeDeleted())
// {
// GooRoomVirtualClient::Instance().RemoveTemporaryCFConnection(connection.get());
// }
// }
if( m_IsPaused )
{
return;
}
Task* task = m_TaskQueue.Pop();
while( task != nullptr )
{
task->Execute();
delete task;
task = nullptr;
availableTimeSlice = timeSliceMil - (clientTimer.Check()-startTime);
if( availableTimeSlice <= milliseconds(0) )
{
return;
}
if( m_IsPaused )
{
return;
}
task = m_TaskQueue.Pop();
}
}
示例3: run
void TaskQueue::run( )
{
RunProlog();
Task *pTask;
LOG(VB_UPNP, LOG_INFO, "TaskQueue Thread Running.");
while ( !m_bTermRequested )
{
// ------------------------------------------------------------------
// Process Any Tasks that may need to be executed.
// ------------------------------------------------------------------
TaskTime ttNow;
gettimeofday( (&ttNow), nullptr );
if ((pTask = GetNextExpiredTask( ttNow )) != nullptr)
{
try
{
pTask->Execute( this );
pTask->DecrRef();
}
catch( ... )
{
LOG(VB_GENERAL, LOG_ERR, "Call to Execute threw an exception.");
}
}
// Make sure to throttle our processing.
msleep( 100 );
}
RunEpilog();
}
示例4: ExecuteTasks
void TaskProxy::ExecuteTasks( bool _bUseCallerThread, const uint32 _cnWaitTask )
{
const Array<WorkerThread*>& rvpThreadPool = WorkerThreadManager::s_GetInstance()->_GetPool();
uint32 i, nThread = rvpThreadPool.size();
uint32 iFinishedTask = 0;
// Define proxy for threads
for( i = 0; i < nThread; i++ )
rvpThreadPool[i]->SetTaskProxy( this );
if( _bUseCallerThread )
{
Task* pTask = NULL;
while( (pTask = PopTask()) != NULL )
{
pTask->Execute();
iFinishedTask++;
}
}
// Wait other threads completion
while( iFinishedTask != _cnWaitTask )
{
for( i = 0; i < nThread; i++ )
{
if( rvpThreadPool[i]->PopFinishedTask() )
iFinishedTask++;
}
}
// Remove proxy once finished
for( i = 0; i < nThread; i++ )
rvpThreadPool[i]->SetTaskProxy( NULL );
}