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

Method internal_insert_if_not_full

benchmarks/tbb/concurrent_queue.cpp:500–518  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

498}
499
500bool concurrent_queue_base_v3::internal_insert_if_not_full( const void* src, copy_specifics op_type ) {
501 concurrent_queue_rep& r = *my_rep;
502 ticket k = r.tail_counter;
503 for(;;) {
504 if( (ptrdiff_t)(k-r.head_counter)>=my_capacity ) {
505 // Queue is full
506 return false;
507 }
508 // Queue had empty slot with ticket k when we looked. Attempt to claim that slot.
509 ticket tk=k;
510 k = r.tail_counter.compare_and_swap( tk+1, tk );
511 if( k==tk )
512 break;
513 // Another thread claimed the slot, so retry.
514 }
515 r.choose(k).push(src, k, *this, op_type);
516 r.items_avail.notify( predicate_leq(k) );
517 return true;
518}
519
520ptrdiff_t concurrent_queue_base_v3::internal_size() const {
521 __TBB_ASSERT( sizeof(ptrdiff_t)<=sizeof(size_t), NULL );

Callers

nothing calls this directly

Calls 4

predicate_leqClass · 0.85
compare_and_swapMethod · 0.45
pushMethod · 0.45
notifyMethod · 0.45

Tested by

no test coverage detected