CppCommon
1.0.4.1
C++ Common Library
|
Multiple producers / multiple consumers wait-free ring queue. More...
#include <mpmc_ring_queue.h>
Public Member Functions | |
MPMCRingQueue (size_t capacity) | |
Default class constructor. More... | |
MPMCRingQueue (const MPMCRingQueue &)=delete | |
MPMCRingQueue (MPMCRingQueue &&)=delete | |
~MPMCRingQueue () | |
MPMCRingQueue & | operator= (const MPMCRingQueue &)=delete |
MPMCRingQueue & | operator= (MPMCRingQueue &&)=delete |
operator bool () const noexcept | |
Check if the queue is not empty. More... | |
bool | empty () const noexcept |
Is ring queue empty? More... | |
size_t | capacity () const noexcept |
Get ring queue capacity. More... | |
size_t | size () const noexcept |
Get ring queue size. More... | |
bool | Enqueue (const T &item) |
Enqueue an item into the ring queue (multiple producers threads method) More... | |
bool | Enqueue (T &&item) |
Enqueue an item into the ring queue (multiple producers threads method) More... | |
bool | Dequeue (T &item) |
Dequeue an item from the ring queue (multiple consumers threads method) More... | |
Multiple producers / multiple consumers wait-free ring queue.
Multiple producers / multiple consumers wait-free ring queue use only atomic operations to provide thread-safe enqueue and dequeue operations. Ring queue size is limited to the capacity provided in the constructor.
FIFO order is guaranteed!
Thread-safe.
C++ implementation of Dmitry Vyukov's non-intrusive lock free unbound MPSC queue http://www.1024cores.net/home/lock-free-algorithms/queues/non-intrusive-mpsc-node-based-queue
Definition at line 33 of file mpmc_ring_queue.h.
|
inlineexplicit |
Default class constructor.
capacity | - Ring queue capacity (must be a power of two) |
Definition at line 12 of file mpmc_ring_queue.inl.
|
delete |
|
delete |
|
inline |
Definition at line 43 of file mpmc_ring_queue.h.
|
inlinenoexcept |
Get ring queue capacity.
Definition at line 54 of file mpmc_ring_queue.h.
|
inline |
Dequeue an item from the ring queue (multiple consumers threads method)
The item will be moved from the ring queue.
Will not block.
item | - Item to dequeue |
Definition at line 89 of file mpmc_ring_queue.inl.
|
inlinenoexcept |
Is ring queue empty?
Definition at line 52 of file mpmc_ring_queue.h.
|
inline |
Enqueue an item into the ring queue (multiple producers threads method)
The item will be copied into the ring queue.
Will not block.
item | - Item to enqueue |
Definition at line 37 of file mpmc_ring_queue.inl.
|
inline |
Enqueue an item into the ring queue (multiple producers threads method)
The item will be moved into the ring queue.
Will not block.
item | - Item to enqueue |
Definition at line 44 of file mpmc_ring_queue.inl.
|
inlineexplicitnoexcept |
Check if the queue is not empty.
Definition at line 49 of file mpmc_ring_queue.h.
|
delete |
|
delete |
|
inlinenoexcept |
Get ring queue size.
Definition at line 28 of file mpmc_ring_queue.inl.