Struct SCMPQueue

Lock-free 1-to-many queue, either single consumer multi producers, or single producer multi consumers. The queue sacrifices fairness to efficiency. The size of the queue should be much larger than the thread count to make sure all threads get the produce. The consuming part is naturally not as important, as we're willing to "waste" threads as long as the queue is constantly depleted.

struct SCMPQueue(T, ulong size) ;

There is a STRONG assumption that the single part NEVER CHANGES ITS EXECUTING CPU CORE. The single (producer/consumer) is not marked as shared, and may not be correct if that role is moved to another core.

Single consumer multiple producers queue

Properties

NameTypeDescription
effectiveCapacity[get] size_tReport the effective capacity of the queue.
isFull[get] boolReport whether the queue is currently full.

Methods

NameDescription
addProducer Register number of producers
addProducers Register number of producers
pop Pop a value from the queue
push push a value into the queue.

Parameters

NameDescription
T the type handled by the queue. Must be one that supports atomic operations.
size the number of raw elements in the queue (actual queue size will be somewhat smaller). Must be a power of 2.