Embedded Multicore Building Blocks V1.0.0
|
Concept for thread-safe queues. More...
Classes | |
class | embb::containers::LockFreeMPMCQueue< Type, ValuePool > |
Lock-free queue for multiple producers and multiple consumers. More... | |
class | embb::containers::WaitFreeSPSCQueue< Type, Allocator > |
Wait-free queue for a single producer and a single consumer. More... | |
Concept for thread-safe queues.
TryEnqueue
and TryDequeue
. TryEnqueue
tries to add an element to the collection, and TryDequeue
tries to remove an element from the collection. A queue has per-thread FIFO (First-In, First-out) semantics, i.e., if one thread enqueues two elements and another thread dequeues these elements, then they appear in the same order. The capacity cap
of a queue defines the number of elements it can store (depending on the implementation, a queue might store more than cap
elements, since for thread-safe memory management, more memory than necessary for holding cap
elements has to be provided).Queue
be the queue classType
be the element type of the queuecapacity
be a value of type size_t
element
be a reference to an element of type Type
Expression | Return type | Description |
---|---|---|
Queue<Type>(capacity) | Nothing | Constructs a queue with minimal capacity capacity that holds elements of type T . |
TryEnqueue(element) | bool | Tries to enqueue element into the queue. Returns false if the queue is full, otherwise true . |
TryDequeue(element) | bool | Tries to dequeue an element from the queue. Returns false if the queue is empty, otherwise true . In the latter case, the dequeued element is stored in element which must be passed by reference. |