Lock-free queue for multiple producers and multiple consumers.
More...
#include <lock_free_mpmc_queue.h>
template<typename Type, typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false >>
class embb::containers::LockFreeMPMCQueue< Type, ValuePool >
Lock-free queue for multiple producers and multiple consumers.
- Implemented concepts:
- Queue Concept
- See also
- WaitFreeSPSCQueue
- Template Parameters
-
Type | Type of the queue elements |
ValuePool | Type of the value pool used as basis for the ObjectPool which stores the elements. |
template<typename Type , typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false >>
Creates a queue with the specified capacity.
- Dynamic memory allocation
- Let
t
be the maximum number of threads and x
be 2.5*t+1
. Then, x*(3*t+1)
elements of size sizeof(void*)
, x
elements of size sizeof(Type)
, and capacity+1
elements of size sizeof(Type)
are allocated.
- Concurrency
- Not thread-safe
- See also
- Queue Concept
- Parameters
-
[in] | capacity | Capacity of the queue |
template<typename Type , typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false >>
Destroys the queue.
- Concurrency
- Not thread-safe
template<typename Type , typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false >>
Returns the capacity of the queue.
- Returns
- Number of elements the queue can hold.
- Concurrency
- Thread-safe and wait-free
template<typename Type , typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false >>
Tries to enqueue an element into the queue.
- Returns
true
if the element could be enqueued, false
if the queue is full.
- Concurrency
- Thread-safe and lock-free
- Note
- It might be possible to enqueue more elements into the queue than its capacity permits.
- See also
- Queue Concept
- Parameters
-
[in] | element | Const reference to the element that shall be enqueued |
template<typename Type , typename ValuePool = embb::containers::LockFreeTreeValuePool < bool, false >>
Tries to dequeue an element from the queue.
- Returns
true
if an element could be dequeued, false
if the queue is empty.
- Concurrency
- Thread-safe and lock-free
- See also
- Queue Concept
- Parameters
-
[in,out] | element | Reference to the dequeued element. Unchanged, if the operation was not successful. |