19 struct alignas(2 * sizeof(Node*))
PTag
50 node->
data = std::forward<U>(value);
55 PTag old_top =
mTop.load(std::memory_order_relaxed);
60 PTag new_top{node, old_top.
tag + 1};
61 if (
mTop.compare_exchange_weak(old_top, new_top, std::memory_order_acquire, std::memory_order_relaxed))
76 PTag old_top =
mTop.load(std::memory_order_relaxed);
77 while (old_top.
p !=
nullptr)
81 if (
mTop.compare_exchange_weak(old_top, new_top, std::memory_order_acquire, std::memory_order_relaxed))
83 out = std::move(old_top.
p->
data);
Allocator interface (noexcept)
Definition Allocator.hpp:29
virtual void Deallocate(pointer ptr) noexcept=0
virtual pointer Allocate(size_type size, size_t alignment=alignof(std::max_align_t)) noexcept=0
Atomic, unbounded LIFO stack with lock-free push and pop operations.
Definition AtomicStack.hpp:16
AtomicStack(Allocator *alloc)
Construct the Stack.
Definition AtomicStack.hpp:39
Atomic< PTag > mTop
Definition AtomicStack.hpp:31
bool Pop(T &out)
Pop a value from the stack.
Definition AtomicStack.hpp:74
void Push(U &&value)
Push a value onto the stack.
Definition AtomicStack.hpp:47
~AtomicStack()
Definition AtomicStack.hpp:91
Allocator * mAlloc
Definition AtomicStack.hpp:32
Lock-free atomic primitives and implementations of data structures.
Definition Allocator.hpp:6
std::atomic< T > Atomic
Alias of std::atomic<T>.
Definition Atomic.hpp:26
Definition AtomicStack.hpp:25
PTag next
Definition AtomicStack.hpp:26
T data
Definition AtomicStack.hpp:27
Definition AtomicStack.hpp:20
uintptr_t tag
Definition AtomicStack.hpp:22
Node * p
Definition AtomicStack.hpp:21