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
Name | Type | Description |
---|---|---|
effectiveCapacity [get]
|
size_t | Report the effective capacity of the queue. |
isFull [get]
|
bool | Report whether the queue is currently full. |
Methods
Name | Description |
---|---|
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
Name | Description |
---|---|
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. |