1#ifndef MRS_LIB_CORO_RUNNERS_HPP_
2#define MRS_LIB_CORO_RUNNERS_HPP_
7#include <mrs_lib/coro/internal/thread_local_continuation_scheduler.hpp>
8#include <mrs_lib/coro/task.hpp>
13namespace mrs_lib::coro
34 template <
typename... Args>
35 promise_type(std::stop_token stop_token, Args&&...) : stop_token_(std::move(stop_token))
43 MoveToThreadLocalContinuationScheduler initial_suspend()
47 std::suspend_never final_suspend() noexcept
54 void unhandled_exception()
59 std::stop_token stop_token_;
74 static std::stop_token get_token(std::coroutine_handle<AsyncRun::promise_type> handle)
76 return handle.promise().stop_token_;
93 template <
typename F,
typename... Args>
94 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>...>>
99 co_await std::invoke(std::move(task), std::move(args)...);
116 template <
typename F,
typename... Args>
117 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>...>>
118 void start_task(F&& task, Args&&... args)
120 internal::start_task_impl(std::stop_token(), std::forward<F>(task), std::forward<Args>(args)...);
138 template <
typename F,
typename... Args>
139 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>...>>
140 void start_task(std::stop_token token, F&& task, Args&&... args)
142 internal::start_task_impl(token, std::forward<F>(task), std::forward<Args>(args)...);
Coroutine type used to start asynchronous computation.
Definition runners.hpp:27
Owning coroutine handle supporting cancellation.
Definition continuation.hpp:54
Definition runners.hpp:30
promise_type(std::stop_token stop_token, Args &&...)
Construct the promise type, storing the associated stop token.
Definition runners.hpp:35
Type trait to obtain data necessary for creating CancellableContinuation.
Definition continuation.hpp:37