Wait-free queue for a single producer and a single consumer.
More...
#include <wait_free_spsc_queue.h>
template<typename Type, class Allocator = embb::base::Allocator< Type >>
class embb::containers::WaitFreeSPSCQueue< Type, Allocator >
Wait-free queue for a single producer and a single consumer.
- Implemented concepts:
- Queue Concept
- See also
- LockFreeMPMCQueue
- Template Parameters
-
Type | Type of the queue elements |
Allocator | Allocator type for allocating queue elements. |
template<typename Type , class Allocator = embb::base::Allocator< Type >>
Creates a queue with at least the specified capacity.
- Dynamic memory allocation
- Allocates
2^k
elements of type Type
, where k
is the smallest number such that capacity <= 2^k
holds.
- Concurrency
- Not thread-safe
- See also
- Queue Concept
- Parameters
-
[in] | capacity | Capacity of the queue |
template<typename Type , class Allocator = embb::base::Allocator< Type >>
Destroys the queue.
- Concurrency
- Not thread-safe
template<typename Type , class Allocator = embb::base::Allocator< Type >>
Returns the capacity of the queue.
- Returns
- Number of elements the queue can hold.
- Concurrency
- Thread-safe and wait-free
template<typename Type , class Allocator = embb::base::Allocator< Type >>
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 wait-free
- Note
- Concurrently enqueueing elements by multiple producers leads to undefined behavior.
- See also
- Queue Concept
- Parameters
-
[in] | element | Const reference to the element that shall be enqueued |
template<typename Type , class Allocator = embb::base::Allocator< Type >>
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 wait-free
- Note
- Concurrently dequeueing elements by multiple consumers leads to undefined behavior.
- See also
- Queue Concept
- Parameters
-
[in,out] | element | Reference to the dequeued element. Unchanged, if the operation was not successful. |