本文整理汇总了C++中TaskQueue::pop方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskQueue::pop方法的具体用法?C++ TaskQueue::pop怎么用?C++ TaskQueue::pop使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskQueue
的用法示例。
在下文中一共展示了TaskQueue::pop方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: updateFramesPointers
void TaskScheduler::updateFramesPointers(TaskQueue& queue)
{
TaskQueue newQueue;
while(!queue.empty())
{
newQueue.push(updateFramesPointers(queue.pop()));
}
while(!newQueue.empty())
{
queue.push(newQueue.pop());
}
}
示例2: operator
void operator()()
{
while(true){
TaskInfoPtr info = TaskInfoPtr();
task_queue.pop(info);
if (info)
ExecuteTask(info);
}
}
示例3: cleanup_task
void cleanup_task()
{
TaskPtr t;
while(!qu.empty())
{
t=qu.front();
qu.pop();
delete t;
}
TaskArray::iterator it = qu_back.begin();
for(; it != qu_back.end(); ++it)
{
t= *it;
delete t;
}
qu_back.clear();
tasklist.clear();
}
示例4: serve_queue
TaskPtr serve_queue()
{
TaskPtr t = qu.front();
LOG_STRING("task %d", t->id);
g_tqs = TQS_BUSY;
if (run_task(t)) // Failed
{
LOG_STRING("task %d failed", t->id);
return 0;
}
qu.pop();
qu_back.push_back(t);
if (qu.empty())
{
g_tqs = TQS_FINISHED;
}
return t;
}
示例5: main
int main()
{
LOG( "__cplusplus = " << __cplusplus );
//const std::function<void()> lambda( [=] () { Log.log( "task1" ); } );
//Task task( lambda );
Task task1( [=] () { Log.log( "task1" ); } );
Task task2( [=] () { Log.log( "task2" ); } );
Task task3( [=] () { Log.log( "task3" ); } );
Task task2dummy( [=] () { Log.log( "task2dummy" ); } );
Task functask( func );
Task task2copy( std::forward<Task>( task2dummy ) ); //misassignment
task2copy = std::forward<Task>( task2 ); //reassignment test
TaskQueue queue;
queue.push( task1 );
const Task *ptask = queue.pop();
if( ptask ) {
( *ptask )();
}
queue.push( task2copy );
ptask = queue.pop();
if( ptask ) {
( *ptask )();
}
queue.push( task3 );
ptask = queue.pop();
if( ptask ) {
( *ptask )();
}
ptask = queue.pop();
if( ptask ) {
( *ptask )();
}
queue.push( task3 );
queue.push( functask );
ptask = queue.pop();
if( ptask ) {
( *ptask )();
*const_cast<Task*>( ptask ) = ( [=] () { Log.log( "reuse1" ); } );
queue.push( *ptask );
ptask = queue.pop();
( *ptask )();
}
ptask = queue.pop();
if( ptask ) {
( *ptask )();
*const_cast<Task*>( ptask ) = std::forward<Func>( func );
queue.push( *ptask );
ptask = queue.pop();
( *ptask )();
}
ptask = queue.pop();
if( ptask ) {
( *ptask )();
}
const std::function<void()> func1( [=] () { Log.log( "func1" ); } );
const std::function<void()> func2( [=] () { Log.log( "func2" ); } );
const std::function<void()> func3( [=] () { Log.log( "func3" ); } );
const std::function<void()> func4( [=] () { Log.log( "func4" ); } );
FuncQueue fqueue;
fqueue.push( func1 );
fqueue.push( func2 );
std::function<void()> ofunc;
if( fqueue.pop( ofunc ) ) {
ofunc();
}
fqueue.push( func3 );
if( fqueue.pop( ofunc ) ) {
ofunc();
}
if( fqueue.pop( ofunc ) ) {
ofunc();
}
if( fqueue.pop( ofunc ) ) {
ofunc();
}
fqueue.push( func3 );
if( fqueue.pop( ofunc ) ) {
ofunc();
}
fqueue.push( func4 );
if( fqueue.pop( ofunc ) ) {
ofunc();
}
if( 0 )
{
Log.log( "Worker test" );
Worker worker( "WorkerA" );
worker.start( [] ( std::thread& ) -> int {
Log.log( "TODO: set thread affinity" );
return 0;
} );
LOG( "Worker " << worker.name() << " started" );
worker.send( task1 );
worker.send( task2 );
worker.send( task3 );
LOG( "Worker " << worker.name() << " sending stop" );
worker.send_stop();
//LOG( "Waiting until worker " << worker.name() << " stopped ..." );
//.........这里部分代码省略.........