Atomic, unbounded LIFO stack with lock-free push and pop operations.
More...
#include <AtomicStack.hpp>
template<typename T>
class Foundation::Core::AtomicStack< T >
Atomic, unbounded LIFO stack with lock-free push and pop operations.
- Note
- Memory allocations are performed on each push and deallocations on each pop. This also requires a thread-safe Allocator, which Core provides.
-
Consider using AtomicPool for fixed-size allocations to reduce allocation overhead if a max-bound is known.
- Template Parameters
-
| T | Data type, must be default constructible. |
◆ AtomicStack()
Construct the Stack.
- Parameters
-
| alloc | Allocator to use for element allocations. |
◆ ~AtomicStack()
◆ Pop()
Pop a value from the stack.
- Parameters
-
| out | Reference to receive the popped value. This is only valid if the function returns true. |
- Note
- Multiple threads may call this concurrently.
- Returns
- True if a value was popped, false if the stack was empty.
◆ Push()
template<typename T >
template<typename U >
Push a value onto the stack.
- Note
- Multiple threads may call this concurrently.
- Template Parameters
-
| U | Type of the value to push. May be different from T, but must be convertible to T. |
- Parameters
-
| value | The value to push. This is forwarded to T's constructor. |
◆ mAlloc
◆ mTop
The documentation for this class was generated from the following file: