1#ifndef MRS_LIB_CORO_RUNNERS_HPP_
2#define MRS_LIB_CORO_RUNNERS_HPP_
9#include "mrs_lib/coro/internal/thread_local_continuation_scheduler.hpp"
10#include "mrs_lib/coro/task.hpp"
12namespace mrs_lib::coro
33 template <
typename... Args>
34 promise_type(std::stop_token stop_token, Args&&...) : stop_token_(std::move(stop_token))
38 AsyncRun get_return_object()
42 MoveToThreadLocalContinuationScheduler initial_suspend()
46 std::suspend_never final_suspend() noexcept
53 void unhandled_exception();
55 std::stop_token stop_token_;
70 static std::stop_token get_token(std::coroutine_handle<AsyncRun::promise_type> handle)
72 return handle.promise().stop_token_;
89 template <
typename F,
typename... Args>
90 requires std::invocable<std::decay_t<F>, std::decay_t<Args>...> && std::same_as<Task<void>, std::invoke_result_t<std::decay_t<F>, std::decay_t<Args>...>>
95 co_await std::invoke(std::move(task), std::move(args)...);
119 template <
typename F,
typename... Args>
120 requires std::invocable<std::decay_t<F>, std::decay_t<Args>...> && std::same_as<Task<void>, std::invoke_result_t<std::decay_t<F>, std::decay_t<Args>...>>
121 void start_task(F&& task, Args&&... args)
123 internal::start_task_impl(std::stop_token(), std::forward<F>(task), std::forward<Args>(args)...);
148 template <
typename F,
typename... Args>
149 requires std::invocable<std::decay_t<F>, std::decay_t<Args>...> && std::same_as<Task<void>, std::invoke_result_t<std::decay_t<F>, std::decay_t<Args>...>>
150 void start_task(std::stop_token token, F&& task, Args&&... args)
152 internal::start_task_impl(token, std::forward<F>(task), std::forward<Args>(args)...);
Coroutine type used to start asynchronous computation.
Definition runners.hpp:26
Owning coroutine handle supporting cancellation.
Definition continuation.hpp:54
promise_type(std::stop_token stop_token, Args &&...)
Construct the promise type, storing the associated stop token.
Definition runners.hpp:34
Type trait to obtain data necessary for creating CancellableContinuation.
Definition continuation.hpp:37