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

API reference / Collections

BoundedPointerQueue class

A bounded, lock-free, multi-producer multi-consumer queue for pointers.

Use
import ThinkMeta.ConcurrentTasks.Collections.BoundedPointerQueue;
Namespace
ThinkMeta::ConcurrentTasks::Collections

Syntax

template <typename T>
using BoundedPointerQueue = Cpp::Padded<_BoundedPointerQueue<T>>;

Template parameters

Ttypename
The pointee type; the queue holds T* and does not own them.

Remarks

Meant for cases where the number of elements is known and bounded, such as the scheduler's task queues. The capacity is set once, at run time, by Initialize and is a power of two. It must cover the maximum number of elements the use case can hold at once: enqueueing into a full queue is invalid use and leaves the queue unusable.

See also

BoundedPointerQueue

Names

NameDescription
BoundedPointerQueue A bounded, lock-free, multi-producer multi-consumer FIFO of pointers.

Holds T* pointers and occupies whole cache lines of its own (Cpp::Padded). Construct, then BoundedPointerQueue::Initialize with a power-of-two capacity.

Constructors

BoundedPointerQueue

Constructs a queue without storage.

Syntax

Remarks

Initialize must succeed before the queue is used.

~BoundedPointerQueue

Frees the ring.

Syntax

~BoundedPointerQueue() noexcept;

Remarks

Pointers still in the queue are not touched (not owned).

Methods

Initialize

Allocates the ring.

Syntax

bool Initialize(std::size_t capacity) noexcept;

Parameters

capacitystd::size_t
Number of slots; must be a power of two and at least 2.

Return value

Type: bool

true on success; false if the memory could not be allocated.

Remarks

Call once, before the queue is shared.

See also

Capacity

Capacity

The number of slots, 0 before Initialize.

Syntax

std::size_t Capacity() const noexcept;

Return value

Type: std::size_t

The capacity passed to Initialize, or 0.

Enqueue

Enqueues a pointer.

Syntax

void Enqueue(T* ptr) noexcept;

Parameters

ptrT*
Pointer to enqueue. Must not be nullptr.

Remarks

Lock-free; callable from any number of threads at once. The queue must not be full (see the capacity rule above).

See also

Dequeue

Dequeue

Dequeues a pointer.

Syntax

T* Dequeue() noexcept;

Return value

Type: T*

The dequeued pointer, or nullptr if the queue is empty.

Remarks

Lock-free; callable from any number of threads at once. Under contention the queue can look empty for a moment while another consumer is taking an element, so nullptr means "try again later", not proof of emptiness.

See also

Enqueue

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