MCPcopy Create free account
hub / github.com/cameron314/readerwriterqueue / size_approx

Function size_approx

readerwriterqueue.h:493–506  ·  view source on GitHub ↗

Returns the approximate number of items currently in the queue. Safe to call from both the producer and consumer threads.

Source from the content-addressed store, hash-verified

491 // Returns the approximate number of items currently in the queue.
492 // Safe to call from both the producer and consumer threads.
493 inline size_t size_approx() const AE_NO_TSAN
494 {
495 size_t result = 0;
496 Block* frontBlock_ = frontBlock.load();
497 Block* block = frontBlock_;
498 do {
499 fence(memory_order_acquire);
500 size_t blockFront = block->front.load();
501 size_t blockTail = block->tail.load();
502 result += (blockTail - blockFront) & block->sizeMask;
503 block = block->next.load();
504 } while (block != frontBlock_);
505 return result;
506 }
507
508 // Returns the total number of items that could be enqueued without incurring
509 // an allocation when this queue is empty.

Callers

nothing calls this directly

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected