31#include <gtest/gtest.h>
39#if ALEPH_HAS_EXPERIMENTAL_ASYNC
46#if ALEPH_HAS_EXPERIMENTAL_ASYNC
57 std::coroutine_handle<promise_type>::from_promise(*
this));
67 std::coroutine_handle<promise_type>
handle_;
100 template <
typename T>
113 std::coroutine_handle<promise_type>::from_promise(*
this));
121 promise_.set_value(std::move(value));
126 promise_.set_exception(std::current_exception());
131 std::coroutine_handle<promise_type>
handle_;
173 const int first =
co_await experimental::schedule(pool, [] {
return 20; });
174 const int second =
co_await experimental::schedule(pool, [first] {
181 std::shared_future<void>
gate,
185 co_await experimental::schedule(pool, [
gate,
started = std::move(
started)]()
mutable {
190 resumed.store(
true, std::memory_order_release);
197 auto op = experimental::schedule(pool, [] {
return 42; });
205 auto op = experimental::schedule(pool, []() ->
int {
206 throw std::runtime_error(
"boom");
215 auto op = experimental::schedule(pool, [] {
216 return std::make_unique<int>(17);
219 auto value = op.get();
234 auto op = experimental::schedule(pool, [] {
return 5; });
245 auto op = experimental::schedule(pool, [] {});
260 std::atomic<bool>
resumed{
false};
268 std::this_thread::sleep_for(std::chrono::milliseconds(20));
A reusable thread pool for efficient parallel task execution.
Opt-in experimental coroutine-friendly bridge over ThreadPool.
#define ALEPH_HAS_EXPERIMENTAL_ASYNC
Main namespace for Aleph-w library functions.
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.
std::decay_t< typename HeadC::Item_Type > T
A modern, efficient thread pool for parallel task execution.