| 498 | } |
| 499 | |
| 500 | bool 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 | |
| 520 | ptrdiff_t concurrent_queue_base_v3::internal_size() const { |
| 521 | __TBB_ASSERT( sizeof(ptrdiff_t)<=sizeof(size_t), NULL ); |
nothing calls this directly
no test coverage detected