Embedded Multicore Building Blocks V1.0.0
Classes
Stack Concept

Concept for thread-safe stacks. More...

Classes

class  embb::containers::LockFreeStack< Type, ValuePool >
 Lock-free stack. More...
 

Detailed Description

Concept for thread-safe stacks.

Description
A stack is an abstract data type holding a collection of elements of some predetermined type. A stack provides two operations: TryPush and TryPop. TryPush tries to add an element to the collection, and TryPop tries to remove an element from the collection. A stack has LIFO (Last-In, First-out) semantics, i.e., the last element added to the collection (TryPush) is removed first (TryPop). The capacity cap of a stack defines the number of elements it can store (depending on the implementation, a stack 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 Stack be the stack class
  • Let Type be the element type of the stack
  • 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
Stack<Type>(capacity)
Nothing Constructs a stack with capacity capacity that holds elements of type Type.
TryPush(element)
bool
Tries to push element onto the stack. Returns false if the stack is full, otherwise true.
TryPop(element)
bool
Tries to pop an element from the stack. Returns false if the stack is empty, otherwise true. In the latter case, the popped element is stored in element which must be passed by reference.