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

Function max_capacity

readerwriterqueue.h:517–527  ·  view source on GitHub ↗

Returns the total number of items that could be enqueued without incurring an allocation when this queue is empty. Safe to call from both the producer and consumer threads. NOTE: The actual capacity during usage may be different depending on the consumer. If the consumer is removing elements concurrently, the producer cannot add to the block the consumer is removing from until it's completely emp

Source from the content-addressed store, hash-verified

515 // the case where the producer was writing to the same block the consumer was
516 // reading from the whole time.
517 inline size_t max_capacity() const {
518 size_t result = 0;
519 Block* frontBlock_ = frontBlock.load();
520 Block* block = frontBlock_;
521 do {
522 fence(memory_order_acquire);
523 result += block->sizeMask;
524 block = block->next.load();
525 } while (block != frontBlock_);
526 return result;
527 }
528
529
530private:

Callers

nothing calls this directly

Calls 1

loadMethod · 0.80

Tested by

no test coverage detected