20 std::cout <<
"Example 1: bounded_channel with TaskGroup\n";
28 for (
int i = 1; i <= 8; ++i)
38 out.push_back(*item * *item);
40 processed.with_write_lock([](
int & value) { ++value; });
52 std::cout <<
"Squares:";
53 for (
const int value :
sorted)
54 std::cout <<
" " << value;
55 std::cout <<
"\nProcessed count: "
56 <<
processed.with_read_lock([](
const int & value) {
return value; })
59 std::cout <<
"Example 2: cancellation-aware recv\n";
66 std::cout <<
"unexpected success\n";
70 std::cout <<
"recv interrupted by cancellation\n";
73 std::cout <<
"\nExample 3: spsc_queue handoff\n";
78 auto second =
handoff.try_pop();
79 std::cout <<
"Popped:";
80 if (first.has_value())
81 std::cout <<
" " << *first;
82 if (second.has_value())
83 std::cout <<
" " << *second;
Bounded blocking channel for producer-consumer workflows.
Cooperative cancellation source paired with CancellationToken.
CancellationToken token() const noexcept
Return a token observing this source.
void request_cancel() noexcept
Request cancellation for all derived tokens.
Read/write-lock protected shared object wrapper.
Bounded single-producer/single-consumer queue.
Mutex-protected shared object wrapper.
Minimal structured-concurrency helper over ThreadPool futures.
A reusable thread pool for efficient parallel task execution.
Exception thrown when cooperative cancellation is observed.
Modern synchronization helpers for channels, shared state, and small producer-consumer queues.
Main namespace for Aleph-w library functions.
Itor2 copy(Itor1 sourceBeg, const Itor1 &sourceEnd, Itor2 destBeg)
Copy elements from one range to another.
Divide_Conquer_DP_Result< Cost > divide_and_conquer_partition_dp(const size_t groups, const size_t n, Transition_Cost_Fn transition_cost, const Cost inf=dp_optimization_detail::default_inf< Cost >())
Optimize partition DP using divide-and-conquer optimization.
A modern, efficient thread pool for parallel task execution.