6 namespace honey {
namespace lockfree
38 Node* node = _freeList.
construct(forward<T_>(val),
nullptr);
45 node->next = old ? _freeList.
deref(old) :
nullptr;
46 }
while (!_top.cas(TaggedHandle(_freeList.
handle(node), old.
nextTag()), old));
59 node = _freeList.
deref(old);
60 }
while (!_top.cas(TaggedHandle(_freeList.
handle(node->next), old.
nextTag()), old));
63 if (val) val = move(node->val);
76 val = _freeList.
deref(top)->val;
85 bool empty()
const {
return !_size; }
void reserve(szt capacity)
Ensure that enough storage is allocated for a number of elements.
Definition: Stack.h:30
Holds block handle and tag to prevent lock-free ABA issues.
Definition: Pool.h:95
T * construct(Args &&...args)
Construct object and remove from free list.
Definition: FreeList.h:35
Stack(szt capacity=0)
Definition: Stack.h:25
void reserve(szt capacity)
Ensure that enough storage is allocated for a number of objects.
Definition: FreeList.h:27
static optnull_t optnull
Null optional, use to reset an optional to an uninitialized state or test for initialization.
Definition: Optional.h:12
~Stack()
Definition: Stack.h:27
Inherit to declare that class is not copyable.
Definition: Meta.h:286
szt size() const
The number of elements in the stack.
Definition: Stack.h:87
bool pop(optional< T & > val=optnull)
Remove element from the top of the stack and move it into val. Returns true on success, false if there is no element to pop.
Definition: Stack.h:51
Must be a load op. Synchronize with a prior release in another thread.
szt capacity() const
The number of elements for which storage is allocated.
Definition: Stack.h:32
bool empty() const
Check whether the stack does not contain any elements.
Definition: Stack.h:85
bool top(T &val)
Get a copy of the top element. Returns true on success, false if there is no element.
Definition: Stack.h:69
size_t szt
Size type, shorthand for size_t.
Definition: Core.h:90
void destroy(T *ptr)
Destroy object and add to free list.
Definition: FreeList.h:40
void clear()
Remove all elements.
Definition: Stack.h:82
szt capacity() const
The number of objects for which storage is allocated.
Definition: FreeList.h:29
void push(T_ &&val)
Add new element constructed with val onto the top of the stack.
Definition: Stack.h:36
Specialization for references.
Definition: Optional.h:132
T value_type
Definition: Stack.h:23
Int nextTag() const
Definition: Pool.h:107
T * deref(Handle handle) const
Get object from compressed handle.
Definition: FreeList.h:45
Lock-free FILO stack. Uses auto-expanding freelist allocator so memory is only reclaimed upon destruc...
Definition: Stack.h:11
Handle handle(T *ptr) const
Get compressed handle for object.
Definition: FreeList.h:43
Global Honeycomb namespace.