60 std::cout <<
"[1] Single-threaded push/try_pop walkthrough\n";
70 std::cout <<
"popped " <<
out <<
"\n";
71 std::cout <<
"queue empty: " << std::boolalpha << q.
is_empty() <<
"\n\n";
76 std::cout <<
"[2] Four producers feeding one consumer\n";
80 constexpr int items_per_producer = 5000;
83 std::atomic<bool> start{
false};
84 std::vector<std::thread> producers;
87 producers.emplace_back([&, p]
89 while (not start.load(std::memory_order_acquire))
91 for (int i = 0; i < items_per_producer; ++i)
99 start.store(
true, std::memory_order_release);
103 while (consumed <
total)
112 for (
auto & t : producers)
115 std::cout <<
"Consumed " << consumed <<
" jobs from " <<
producer_count
119 <<
" jobs (expected " << items_per_producer <<
")\n";
120 std::cout <<
"queue empty after drain: " << std::boolalpha << q.
is_empty()
127 std::cout <<
"\n=== Aleph::MpscQueue: multi-producer/single-consumer queue ===\n\n";
132 std::cout <<
"Done.\n";
size_t size_t int32_t * out
Unbounded lock-free multi-producer/single-consumer queue.
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.
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.
void print_rule()
Prints a horizontal rule for example output separation.
std::ostream & join(const C &c, const std::string &sep, std::ostream &out)
Join elements of an Aleph-style container into a stream.
Unbounded lock-free multi-producer/single-consumer queue (Aleph::MpscQueue).