Template Class IndexQueue

Nested Relationships

Nested Types

Class Documentation

template<uint64_t Capacity, typename ValueType = uint64_t>
class IndexQueue

lockfree queue capable of storing indices 0,1,… Capacity-1

Public Types

using value_t = ValueType

Public Functions

~IndexQueue() noexcept = default
IndexQueue(const IndexQueue&) = delete
IndexQueue(IndexQueue&&) = delete
IndexQueue &operator=(const IndexQueue&) = delete
IndexQueue &operator=(IndexQueue&&) = delete
IndexQueue(ConstructEmpty_t = ConstructEmpty) noexcept

constructs an empty IndexQueue

IndexQueue(ConstructFull_t) noexcept

constructs IndexQueue filled with all indices 0,1,…capacity-1

constexpr uint64_t capacity() const noexcept

get the capacity of the IndexQueue

Returns:

capacity of the IndexQueue threadsafe, lockfree

bool empty() const noexcept

check whether the queue is empty

Returns:

true iff the queue is empty note that if the queue is used concurrently it might not be empty anymore after the call (but it was at some point during the call)

void push(const ValueType index) noexcept

push index into the queue in FIFO order

Parameters:

index – to be pushed note that do the way it is supposed to be used we cannot overflow (the number of indices available is bounded and the capacity is large enough to hold them all)

cxx::optional<ValueType> pop() noexcept

pop an index from the queue in FIFO order if the queue not empty

Returns:

index if the queue was is empty, nullopt oterwise

cxx::optional<ValueType> popIfFull() noexcept

pop an index from the queue in FIFO order if the queue is full

Returns:

index if the queue was full, nullopt otherwise

cxx::optional<ValueType> popIfSizeIsAtLeast(uint64_t size) noexcept

pop an index from the queue in FIFO order if the queue contains at least a specified number number of elements

Parameters:

size – the number of elements needed to successfully perform the pop

Returns:

index if the queue contains size elements, nullopt otherwise

Public Static Attributes

static constexpr ConstructFull_t ConstructFull = {}
static constexpr ConstructEmpty_t ConstructEmpty = {}
struct ConstructEmpty_t
struct ConstructFull_t