本文整理汇总了C++中TaskQueue::push方法的典型用法代码示例。如果您正苦于以下问题:C++ TaskQueue::push方法的具体用法?C++ TaskQueue::push怎么用?C++ TaskQueue::push使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TaskQueue
的用法示例。
在下文中一共展示了TaskQueue::push方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: main
int main()
{
boost::thread_group worker_threads;
for (int i = 0; i < MAX_THREAD_NUM; i++)
worker_threads.create_thread(Execute(boost::str(boost::format("%d") %(i+1))));
for (int i = 0; i < 20; i++)
task_queue.push(TaskInfoPtr(new TaskInfo(i)));
worker_threads.join_all();
return 0;
}
示例3: add_to_queue
int add_to_queue(TaskPtr t)
{
if (is_task_already_exist(t))
{
LOG_STRING("Task %d duplicated!!", t->id);
return -1;
}
qu.push(t);
tasklist.push_back(t);
return 0;
}
示例4: 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 ..." );
//.........这里部分代码省略.........