Preliminary. ThinkMeta ConcurrentTasks and this documentation are preliminary; everything is subject to change.

API reference / Collections

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 ConcurrentStack

Template parameters

Ttypename
The item type; derives from SLIST_ENTRY, through which items are linked, and is aligned to MEMORY_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

BasicStack

Constructors

ConcurrentStack

Constructs an empty stack.

Syntax

ConcurrentStack() noexcept;

Methods

Push

Pushes an item on top.

Syntax

void Push(T* item) noexcept;

Parameters

itemT*
Not nullptr; its SLIST_ENTRY::Next is overwritten.

See also

Pop

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

Push

Size

Returns the number of items at the moment of the call.

Syntax

unsigned short Size() const noexcept;

Return value

Type: unsigned short

The item count, modulo 65536.

Remarks

Uses QueryDepthSList; with concurrent Push and Pop the result may be outdated at once. Counts above 65535 wrap (16 bits).

Generated from ThinkMeta.ConcurrentTasks.API @ 137ec1d (2026-10-17).