CppCommon
1.0.4.1
C++ Common Library
|
Multiple producers / multiple consumers wait ring. More...
#include <wait_ring.h>
Public Member Functions | |
WaitRing (size_t capacity) | |
Default class constructor. More... | |
WaitRing (const WaitRing &)=delete | |
WaitRing (WaitRing &&)=delete | |
~WaitRing () | |
WaitRing & | operator= (const WaitRing &)=delete |
WaitRing & | operator= (WaitRing &&)=delete |
operator bool () const noexcept | |
Check if the wait ring is not empty. More... | |
bool | closed () const |
Is wait ring closed? More... | |
bool | empty () const |
Is wait ring empty? More... | |
size_t | capacity () const |
Get wait ring capacity. More... | |
size_t | size () const |
Get wait ring size. More... | |
bool | Enqueue (const T &item) |
Enqueue an item into the wait ring. More... | |
bool | Enqueue (T &&item) |
Enqueue an item into the wait ring. More... | |
bool | Dequeue (T &item) |
Dequeue an item from the wait ring. More... | |
void | Close () |
Close the wait ring. More... | |
Multiple producers / multiple consumers wait ring.
Multiple producers / multiple consumers wait ring provides a classic solution for producer-consumer problem using fixed ring and monitor synchronization primitive (mutex with condition variable).
FIFO order is guaranteed!
https://en.wikipedia.org/wiki/Producer%E2%80%93consumer_problem
Definition at line 30 of file wait_ring.h.
|
inlineexplicit |
Default class constructor.
capacity | - Ring capacity (must be a power of two) |
Definition at line 12 of file wait_ring.inl.
|
delete |
|
delete |
|
inline |
Definition at line 19 of file wait_ring.inl.
|
inline |
Get wait ring capacity.
Definition at line 54 of file wait_ring.h.
|
inline |
Close the wait ring.
Will block.
Definition at line 94 of file wait_ring.inl.
|
inline |
Is wait ring closed?
Definition at line 25 of file wait_ring.inl.
|
inline |
Dequeue an item from the wait ring.
The item will be moved from the wait ring.
Will block.
item | - Item to dequeue |
Definition at line 70 of file wait_ring.inl.
|
inline |
Is wait ring empty?
Definition at line 52 of file wait_ring.h.
|
inline |
Enqueue an item into the wait ring.
The item will be copied into the wait ring.
Will block.
item | - Item to enqueue |
Definition at line 39 of file wait_ring.inl.
|
inline |
Enqueue an item into the wait ring.
The item will be moved into the wait ring.
Will block.
item | - Item to enqueue |
Definition at line 46 of file wait_ring.inl.
|
inlineexplicitnoexcept |
Check if the wait ring is not empty.
Definition at line 46 of file wait_ring.h.
|
delete |
|
delete |
|
inline |
Get wait ring size.
Definition at line 32 of file wait_ring.inl.