CppCommon
1.0.4.1
C++ Common Library
|
Multiple producers / multiple consumers wait queue. More...
#include <wait_queue.h>
Public Member Functions | |
WaitQueue (size_t capacity=0) | |
Default class constructor. More... | |
WaitQueue (const WaitQueue &)=delete | |
WaitQueue (WaitQueue &&)=default | |
~WaitQueue () | |
WaitQueue & | operator= (const WaitQueue &)=delete |
WaitQueue & | operator= (WaitQueue &&)=default |
operator bool () const noexcept | |
Check if the wait queue is not empty. More... | |
bool | closed () const |
Is wait queue closed? More... | |
bool | empty () const |
Is wait queue empty? More... | |
size_t | capacity () const |
Get wait queue capacity. More... | |
size_t | size () const |
Get wait queue size. More... | |
bool | Enqueue (const T &item) |
Enqueue an item into the wait queue. More... | |
bool | Enqueue (T &&item) |
Enqueue an item into the wait queue. More... | |
bool | Dequeue (T &item) |
Dequeue an item from the wait queue. More... | |
void | Close () |
Close the wait queue. More... | |
Multiple producers / multiple consumers wait queue.
Multiple producers / multiple consumers wait queue provides a classic solution for producer-consumer problem using queue 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 29 of file wait_queue.h.
|
inlineexplicit |
Default class constructor.
capacity | - Wait queue capacity (default is 0 for unlimited capacity) |
Definition at line 12 of file wait_queue.inl.
|
delete |
|
default |
|
inline |
Definition at line 17 of file wait_queue.inl.
|
inline |
Get wait queue capacity.
Definition at line 30 of file wait_queue.inl.
|
inline |
Close the wait queue.
Will block.
Definition at line 120 of file wait_queue.inl.
|
inline |
Is wait queue closed?
Definition at line 23 of file wait_queue.inl.
|
inline |
Dequeue an item from the wait queue.
The item will be moved from the wait queue.
Will block.
item | - Item to dequeue |
Definition at line 95 of file wait_queue.inl.
|
inline |
Is wait queue empty?
Definition at line 51 of file wait_queue.h.
|
inline |
Enqueue an item into the wait queue.
The item will be copied into the wait queue.
Will block.
item | - Item to enqueue |
Definition at line 47 of file wait_queue.inl.
|
inline |
Enqueue an item into the wait queue.
The item will be moved into the wait queue.
Will block.
item | - Item to enqueue |
Definition at line 71 of file wait_queue.inl.
|
inlineexplicitnoexcept |
Check if the wait queue is not empty.
Definition at line 45 of file wait_queue.h.
|
delete |
|
default |
|
inline |
Get wait queue size.
Definition at line 40 of file wait_queue.inl.