106#ifndef TPL_MPSC_QUEUE_H
107#define TPL_MPSC_QUEUE_H
131 std::atomic<Node *>
next{
nullptr};
136 template <
typename...
Args>
142 alignas(64) std::atomic<Node *>
head_;
150 n->next.store(
nullptr, std::memory_order_relaxed);
151 Node * prev =
head_.exchange(n, std::memory_order_acq_rel);
152 prev->
next.store(n, std::memory_order_release);
168 Node *
next = tail->
next.load(std::memory_order_acquire);
185 Node * head =
head_.load(std::memory_order_acquire);
190 next = tail->
next.load(std::memory_order_acquire);
277 template <
typename...
Args>
280 Node * n =
new Node(std::in_place, std::forward<Args>(
args)...);
305 std::unique_ptr<Node> owned(n);
306 out = std::move(*owned->value);
327 std::unique_ptr<Node> owned(n);
328 return std::optional<T>(std::move(*owned->value));
344 tail_->
next.load(std::memory_order_acquire) ==
nullptr;
size_t size_t int32_t value
size_t size_t int32_t * out
Unbounded lock-free multi-producer/single-consumer queue.
void push_node(Node *n) noexcept
Publish n as the new last node.
std::atomic< Node * > head_
MpscQueue() noexcept
Construct an empty queue.
~MpscQueue()
Destroy the queue, releasing any still-queued nodes.
void emplace(Args &&... args)
Construct a new element in place at the back of the queue.
void push(const T &value)
Push a copy of value onto the queue.
void push(T &&value)
Push value onto the queue, moving it in.
MpscQueue & operator=(const MpscQueue &)=delete
Deleted copy assignment operator.
MpscQueue(const MpscQueue &)=delete
Deleted copy constructor: the queue owns heap nodes with internal atomics that cannot be safely dupli...
std::optional< T > try_pop()
Attempt to pop the front element.
MpscQueue & operator=(MpscQueue &&)=delete
Deleted move assignment operator.
Node * pop_node() noexcept
Consumer-only: detach and return the front node, or nullptr.
MpscQueue(MpscQueue &&)=delete
Deleted move constructor: producers may hold a reference to a fixed queue address; see the class-leve...
bool is_empty() const noexcept
Advisory check for whether the queue currently has no elements.
bool try_pop(T &out)
Attempt to pop the front element into out.
size_t blossom_maximum_cardinality_matching(const GT &g, DynDlist< typename GT::Arc * > &matching, SA sa=SA())
Alias of compute_maximum_cardinality_general_matching().
Main namespace for Aleph-w library functions.
and
Check uniqueness with explicit hash + equality functors.
std::decay_t< typename HeadC::Item_Type > T
void next()
Advance all underlying iterators (bounds-checked).
std::atomic< Node * > next
Node(std::in_place_t, Args &&... args)