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

Method forward_task

benchmarks/tbb/flow_graph.h:2489–2542  ·  view source on GitHub ↗

only returns a valid task pointer or NULL, never SUCCESSFULLY_ENQUEUED

Source from the content-addressed store, hash-verified

2487
2488 // only returns a valid task pointer or NULL, never SUCCESSFULLY_ENQUEUED
2489 task *forward_task() {
2490 input_type v;
2491 task *rval = NULL;
2492 bool reserved = false;
2493 {
2494 spin_mutex::scoped_lock lock(my_mutex);
2495 if ( check_conditions() )
2496 ++my_tries;
2497 else
2498 return NULL;
2499 }
2500
2501 //SUCCESS
2502 // if we can reserve and can put, we consume the reservation
2503 // we increment the count and decrement the tries
2504 if ( (my_predecessors.try_reserve(v)) == true ){
2505 reserved=true;
2506 if ( (rval = my_successors.try_put_task(v)) != NULL ){
2507 {
2508 spin_mutex::scoped_lock lock(my_mutex);
2509 ++my_count;
2510 --my_tries;
2511 my_predecessors.try_consume();
2512 if ( check_conditions() ) {
2513 task* tp = this->my_graph.root_task();
2514 if ( tp ) {
2515 task *rtask = new ( task::allocate_additional_child_of( *tp ) )
2516 internal::forward_task_bypass< limiter_node<T> >( *this );
2517 FLOW_SPAWN (*rtask);
2518 }
2519 }
2520 }
2521 return rval;
2522 }
2523 }
2524 //FAILURE
2525 //if we can't reserve, we decrement the tries
2526 //if we can reserve but can't put, we decrement the tries and release the reservation
2527 {
2528 spin_mutex::scoped_lock lock(my_mutex);
2529 --my_tries;
2530 if (reserved) my_predecessors.try_release();
2531 if ( check_conditions() ) {
2532 task* tp = this->my_graph.root_task();
2533 if ( tp ) {
2534 task *rtask = new ( task::allocate_additional_child_of( *tp ) )
2535 internal::forward_task_bypass< limiter_node<T> >( *this );
2536 __TBB_ASSERT(!rval, "Have two tasks to handle");
2537 return rtask;
2538 }
2539 }
2540 return rval;
2541 }
2542 }
2543
2544 void forward() {
2545 __TBB_ASSERT(false, "Should never be called");

Callers

nothing calls this directly

Calls 5

root_taskMethod · 0.80
try_reserveMethod · 0.45
try_put_taskMethod · 0.45
try_consumeMethod · 0.45
try_releaseMethod · 0.45

Tested by

no test coverage detected