Embedded Multicore Building Blocks V1.0.0
Classes
Queue Concept

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...
 

Detailed Description

Concept for thread-safe queues.

Description
A queue is an abstract data type holding a collection of elements of some predetermined type. A queue provides two operations: 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).
Requirements
  • Let Queue be the queue class
  • Let Type be the element type of the queue
  • Let capacity be a value of type size_t
  • Let element be a reference to an element of type Type
Valid Expressions
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.