1#ifndef BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED
2#define BEAST_INTRUSIVE_LOCKFREESTACK_H_INCLUDED
12template <
class Container,
bool IsConst>
16 using Node =
typename Container::Node;
26 typename Container::const_pointer,
27 typename Container::pointer>::type;
30 typename Container::const_reference,
31 typename Container::reference>::type;
41 template <
bool OtherIsConst>
94template <
class Container,
bool LhsIsConst,
bool RhsIsConst>
103template <
class Container,
bool LhsIsConst,
bool RhsIsConst>
126template <
class Element,
class Tag =
void>
148 template <
class Container,
bool IsConst>
200 first = (old_head == &
m_end);
202 }
while (!
m_head.compare_exchange_strong(
228 new_head = node->
m_next.load();
229 }
while (!
m_head.compare_exchange_strong(
234 return static_cast<Element*
>(node);
pointer operator->() const
reference operator*() const
LockFreeStackIterator & operator++()
typename Container::Node Node
typename std::conditional< IsConst, typename Container::const_pointer, typename Container::pointer >::type pointer
LockFreeStackIterator & operator=(NodePtr node)
LockFreeStackIterator(LockFreeStackIterator< Container, OtherIsConst > const &other)
LockFreeStackIterator(NodePtr node)
typename Container::value_type value_type
typename std::conditional< IsConst, Node const *, Node * >::type NodePtr
typename Container::difference_type difference_type
typename std::conditional< IsConst, typename Container::const_reference, typename Container::reference >::type reference
LockFreeStackIterator operator++(int)
Node(Node const &)=delete
Node & operator=(Node const &)=delete
std::atomic< Node * > m_next
Multiple Producer, Multiple Consumer (MPMC) intrusive stack.
const_iterator cend() const
bool push_front(Node *node)
Push a node onto the stack.
LockFreeStackIterator< LockFreeStack< Element, Tag >, false > iterator
const_iterator cbegin() const
iterator begin()
Return a forward iterator to the beginning or end of the stack.
Element * pop_front()
Pop an element off the stack.
LockFreeStack(LockFreeStack const &)=delete
bool empty() const
Returns true if the stack is empty.
LockFreeStack & operator=(LockFreeStack const &)=delete
Element const * const_pointer
Element const & const_reference
const_iterator begin() const
std::atomic< Node * > m_head
LockFreeStackIterator< LockFreeStack< Element, Tag >, true > const_iterator
const_iterator end() const
bool operator==(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)
bool operator!=(LockFreeStackIterator< Container, LhsIsConst > const &lhs, LockFreeStackIterator< Container, RhsIsConst > const &rhs)