MCPcopy Create free account
hub / github.com/Snapchat/KeyDB / ConcurrentQueue

Method ConcurrentQueue

deps/concurrentqueue/concurrentqueue.h:792–811  ·  view source on GitHub ↗

Creates a queue with at least `capacity` element slots; note that the actual number of elements that can be inserted without additional memory allocation depends on the number of producers and the block size (e.g. if the block size is equal to `capacity`, only a single block will be allocated up-front, which means only a single producer will be able to enqueue elements without an extra allocation

Source from the content-addressed store, hash-verified

790 // includes making the memory effects of construction visible, possibly with a
791 // memory barrier).
792 explicit ConcurrentQueue(size_t capacity = 6 * BLOCK_SIZE)
793 : producerListTail(nullptr),
794 producerCount(0),
795 initialBlockPoolIndex(0),
796 nextExplicitConsumerId(0),
797 globalExplicitConsumerOffset(0)
798 {
799 implicitProducerHashResizeInProgress.clear(std::memory_order_relaxed);
800 populate_initial_implicit_producer_hash();
801 populate_initial_block_list(capacity / BLOCK_SIZE + ((capacity & (BLOCK_SIZE - 1)) == 0 ? 0 : 1));
802
803#ifdef MOODYCAMEL_QUEUE_INTERNAL_DEBUG
804 // Track all the producers using a fully-resolved typed list for
805 // each kind; this makes it possible to debug them starting from
806 // the root queue object (otherwise wacky casts are needed that
807 // don't compile in the debugger's expression evaluator).
808 explicitProducers.store(nullptr, std::memory_order_relaxed);
809 implicitProducers.store(nullptr, std::memory_order_relaxed);
810#endif
811 }
812
813 // Computes the correct amount of pre-allocated blocks for you based
814 // on the minimum number of elements you want available at any given

Callers

nothing calls this directly

Calls 5

reown_producersFunction · 0.85
clearMethod · 0.45

Tested by

no test coverage detected