ConcurrentStack class
A lock-free intrusive LIFO stack.
- Use
import ThinkMeta.ConcurrentTasks.Collections.ConcurrentStack;- Namespace
ThinkMeta::ConcurrentTasks::Collections
Syntax
template <typename T>
requires std::is_base_of_v<SLIST_ENTRY, T> class ConcurrentStackTemplate parameters
Ttypename- The item type; derives from
SLIST_ENTRY, through which items are linked, and is aligned toMEMORY_ALLOCATION_ALIGNMENT.
Remarks
Push and Pop may be called from any number of threads and tasks at once. Items are linked through their SLIST_ENTRY base, so pushing never allocates. Requirements of the Windows SList apply: every item must be aligned to MEMORY_ALLOCATION_ALIGNMENT (16 bytes on x64), as must the stack object itself. The stack does not own its items; an item must stay alive while it is on the stack. Destroying a non-empty stack just forgets the items.
See also
Constructors
ConcurrentStack
Methods
Push
Pushes an item on top.
Syntax
void Push(T* item) noexcept;Parameters
itemT*- Not
nullptr; itsSLIST_ENTRY::Nextis overwritten.
See also
Pop
Removes and returns the top item.
Syntax
T* Pop() noexcept;Return value
Type: T*
The top item, or nullptr if the stack is empty.
See also
Size
Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).