Embedded Multicore Building Blocks V1.0.0
|
Concept for thread-safe stacks. More...
Classes | |
class | embb::containers::LockFreeStack< Type, ValuePool > |
Lock-free stack. More... | |
Concept for thread-safe stacks.
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).Stack
be the stack classType
be the element type of the stackcapacity
be a value of type size_t
element
be a reference to an element of type Type
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. |