CppCommon
1.0.4.1
C++ Common Library
|
Multiple producers / single consumer wait-free linked batcher. More...
#include <mpsc_linked_batcher.h>
Public Member Functions | |
MPSCLinkedBatcher () | |
MPSCLinkedBatcher (const MPSCLinkedBatcher &)=delete | |
MPSCLinkedBatcher (MPSCLinkedBatcher &&)=delete | |
~MPSCLinkedBatcher () | |
MPSCLinkedBatcher & | operator= (const MPSCLinkedBatcher &)=delete |
MPSCLinkedBatcher & | operator= (MPSCLinkedBatcher &&)=delete |
bool | Enqueue (const T &item) |
Enqueue an item into the linked batcher (multiple producers threads method) More... | |
bool | Enqueue (T &&item) |
Enqueue an item into the linked batcher (multiple producers threads method) More... | |
bool | Dequeue (const std::function< void(const T &)> &handler=[](const int &){}) |
Dequeue all items from the linked queue (single consumer thread method) More... | |
Multiple producers / single consumer wait-free linked batcher.
Multiple producers / single consumer wait-free linked batcher use only atomic operations to provide thread-safe enqueue and batch dequeue operations. Linked batcher is a dynamically grows queue which allocates memory for each new node. It allows a consumer thread to process all items in queue in a batch mode.
FIFO order is guaranteed!
Thread-safe.
Based on Boost Wait-free multi-producer queue http://www.boost.org/doc/libs/1_60_0/doc/html/atomic/usage_examples.html#boost_atomic.usage_examples.mp_queue
Definition at line 33 of file mpsc_linked_batcher.h.
|
inline |
Definition at line 12 of file mpsc_linked_batcher.inl.
|
delete |
|
delete |
|
inline |
Definition at line 17 of file mpsc_linked_batcher.inl.
|
inline |
Dequeue all items from the linked queue (single consumer thread method)
All items in the batcher will be processed by the given handler.
Will not block.
handler | - Batch handler (default is empty handler) |
Definition at line 52 of file mpsc_linked_batcher.inl.
|
inline |
Enqueue an item into the linked batcher (multiple producers threads method)
The item will be copied into the linked batcher.
Will not block.
item | - Item to enqueue |
Definition at line 24 of file mpsc_linked_batcher.inl.
|
inline |
Enqueue an item into the linked batcher (multiple producers threads method)
The item will be moved into the linked batcher.
Will not block.
item | - Item to enqueue |
Definition at line 31 of file mpsc_linked_batcher.inl.
|
delete |
|
delete |