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

Method internal_pop_if_present

benchmarks/tbb/concurrent_queue.cpp:468–490  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

466}
467
468bool concurrent_queue_base_v3::internal_pop_if_present( void* dst ) {
469 concurrent_queue_rep& r = *my_rep;
470 ticket k;
471 do {
472 k = r.head_counter;
473 for(;;) {
474 if( (ptrdiff_t)(r.tail_counter-k)<=0 ) {
475 // Queue is empty
476 return false;
477 }
478 // Queue had item with ticket k when we looked. Attempt to get that item.
479 ticket tk=k;
480 k = r.head_counter.compare_and_swap( tk+1, tk );
481 if( k==tk )
482 break;
483 // Another thread snatched the item, retry.
484 }
485 } while( !r.choose( k ).pop( dst, k, *this ) );
486
487 r.slots_avail.notify( predicate_leq(k) );
488
489 return true;
490}
491
492bool concurrent_queue_base_v3::internal_push_if_not_full( const void* src ) {
493 return internal_insert_if_not_full( src, copy );

Callers

nothing calls this directly

Calls 4

predicate_leqClass · 0.85
compare_and_swapMethod · 0.45
popMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected