| 466 | } |
| 467 | |
| 468 | bool 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 | |
| 492 | bool concurrent_queue_base_v3::internal_push_if_not_full( const void* src ) { |
| 493 | return internal_insert_if_not_full( src, copy ); |
nothing calls this directly
no test coverage detected