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));
60 std::suspend_never initial_suspend()
noexcept {
return {}; }
61 std::suspend_always final_suspend()
noexcept {
return {}; }
63 void unhandled_exception() { std::terminate(); }
67 std::coroutine_handle<promise_type> handle_;
77 : handle_(
other.handle_)
88 handle_ =
other.handle_;
100 template <
typename T>
113 std::coroutine_handle<promise_type>::from_promise(*
this));
116 std::suspend_never initial_suspend()
noexcept {
return {}; }
117 std::suspend_always final_suspend()
noexcept {
return {}; }
119 void return_value(
T value)
124 void unhandled_exception()
126 promise_.set_exception(std::current_exception());
131 std::coroutine_handle<promise_type> handle_;
154 handle_ =
other.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));
size_t size_t int32_t value
A reusable thread pool for efficient parallel task execution.
Opt-in experimental coroutine-friendly bridge over ThreadPool.
#define ALEPH_HAS_EXPERIMENTAL_ASYNC
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.
std::decay_t< typename HeadC::Item_Type > T
A modern, efficient thread pool for parallel task execution.