MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / enqueue_task

Method enqueue_task

benchmarks/tbb/arena.cpp:491–530  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

489#endif /* __TBB_COUNT_TASK_NODES */
490
491void arena::enqueue_task( task& t, intptr_t prio, FastRandom &random )
492{
493#if __TBB_RECYCLE_TO_ENQUEUE
494 __TBB_ASSERT( t.state()==task::allocated || t.state()==task::to_enqueue, "attempt to enqueue task with inappropriate state" );
495#else
496 __TBB_ASSERT( t.state()==task::allocated, "attempt to enqueue task that is not in 'allocated' state" );
497#endif
498 t.prefix().state = task::ready;
499 t.prefix().extra_state |= es_task_enqueued; // enqueued task marker
500
501#if TBB_USE_ASSERT
502 if( task* parent = t.parent() ) {
503 internal::reference_count ref_count = parent->prefix().ref_count;
504 __TBB_ASSERT( ref_count!=0, "attempt to enqueue task whose parent has a ref_count==0 (forgot to set_ref_count?)" );
505 __TBB_ASSERT( ref_count>0, "attempt to enqueue task whose parent has a ref_count<0" );
506 parent->prefix().extra_state |= es_ref_count_active;
507 }
508 __TBB_ASSERT(t.prefix().affinity==affinity_id(0), "affinity is ignored for enqueued tasks");
509#endif /* TBB_USE_ASSERT */
510
511#if __TBB_TASK_PRIORITY
512 intptr_t p = prio ? normalize_priority(priority_t(prio)) : normalized_normal_priority;
513 assert_priority_valid(p);
514 task_stream &ts = my_task_stream[p];
515#else /* !__TBB_TASK_PRIORITY */
516 __TBB_ASSERT_EX(prio == 0, "the library is not configured to respect the task priority");
517 task_stream &ts = my_task_stream;
518#endif /* !__TBB_TASK_PRIORITY */
519 ITT_NOTIFY(sync_releasing, &ts);
520 ts.push( &t, random );
521#if __TBB_TASK_PRIORITY
522 if ( p != my_top_priority )
523 my_market->update_arena_priority( *this, p );
524#endif /* __TBB_TASK_PRIORITY */
525 advertise_new_work< /*Spawned=*/ false >();
526#if __TBB_TASK_PRIORITY
527 if ( p != my_top_priority )
528 my_market->update_arena_priority( *this, p );
529#endif /* __TBB_TASK_PRIORITY */
530}
531
532#if __TBB_TASK_ARENA
533struct nested_arena_context : no_copy {

Callers 4

enqueueMethod · 0.80
internal_enqueueMethod · 0.80
internal_executeMethod · 0.80

Calls 7

normalize_priorityFunction · 0.85
priority_tEnum · 0.85
assert_priority_validFunction · 0.85
stateMethod · 0.80
parentMethod · 0.80
update_arena_priorityMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected