MCPcopy Create free account
hub / github.com/cameron314/concurrentqueue / ConcurrentQueue

Method ConcurrentQueue

concurrentqueue.h:826–845  ·  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

824 // includes making the memory effects of construction visible, possibly with a
825 // memory barrier).
826 explicit ConcurrentQueue(size_t capacity = 32 * BLOCK_SIZE)
827 : producerListTail(nullptr),
828 producerCount(0),
829 initialBlockPoolIndex(0),
830 nextExplicitConsumerId(0),
831 globalExplicitConsumerOffset(0)
832 {
833 implicitProducerHashResizeInProgress.clear(std::memory_order_relaxed);
834 populate_initial_implicit_producer_hash();
835 populate_initial_block_list(capacity / BLOCK_SIZE + ((capacity & (BLOCK_SIZE - 1)) == 0 ? 0 : 1));
836
837#ifdef MOODYCAMEL_QUEUE_INTERNAL_DEBUG
838 // Track all the producers using a fully-resolved typed list for
839 // each kind; this makes it possible to debug them starting from
840 // the root queue object (otherwise wacky casts are needed that
841 // don't compile in the debugger's expression evaluator).
842 explicitProducers.store(nullptr, std::memory_order_relaxed);
843 implicitProducers.store(nullptr, std::memory_order_relaxed);
844#endif
845 }
846
847 // Computes the correct amount of pre-allocated blocks for you based
848 // on the minimum number of elements you want available at any given

Callers

nothing calls this directly

Calls 8

moveFunction · 0.85
reown_producersFunction · 0.85
clearMethod · 0.45
storeMethod · 0.45
loadMethod · 0.45

Tested by

no test coverage detected