30 constexpr void return_void() {}
37 template<
typename promise_type>
40 constexpr bool await_ready()
const noexcept {
return false; }
45 auto &promise = h.promise();
46 if (promise.continuation_)
47 return promise.continuation_;
48 if (promise.exception_)
61 struct ConstantAwaiter {
63 constexpr bool await_ready()
const noexcept {
return true; }
65 T await_resume()
noexcept {
return std::move (value_); }
67 template<
typename T>
decltype(
auto)
68 await_transform (T &&value)
73 else if constexpr (
requires { value.operator
co_await(); })
76 else if constexpr (
requires {
operator co_await (
std::forward<T> (value)); })
81 return ConstantAwaiter<std::remove_cvref_t<T>> {
std::forward<T>(value) };
91template<
typename Result>
102 result_.emplace (std::move (value));
107 result_.emplace (value);
111 constexpr bool await_ready () const noexcept {
return !
frame_ ||
frame_.
done(); }
134 CoTask (CoTask &&o) noexcept :
frame_ (o.frame_) { o.frame_ =
nullptr; }
135 CoTask& operator= (CoTask &&o)
noexcept {
std::swap (
frame_, o.frame_);
return *
this; }
136 CoTask (
const CoTask&) =
delete;
137 CoTask& operator= (
const CoTask&) =
delete;
151 constexpr void return_void()
noexcept {}
154 constexpr bool await_ready () const noexcept {
return !
frame_ ||
frame_.
done(); }
171 CoTask (CoTask &&o) noexcept :
frame_ (o.frame_) { o.frame_ =
nullptr; }
172 CoTask& operator= (CoTask &&o)
noexcept {
std::swap (
frame_, o.frame_);
return *
this; }
173 CoTask (
const CoTask&) =
delete;
174 CoTask& operator= (
const CoTask&) =
delete;
Concept: Is T an awaitable?
T current_exception(T... args)
#define ASE_ASSERT_UNREACHED(...)
Abort and issue an assertion error.
#define ASE_ASSERT_RETURN(expr,...)
Return from the current function if expr evaluates to false and issue an assertion warning.
#define ASE_RETURN_UNLESS(cond,...)
Return silently if cond does not evaluate to true, with return value ...
T from_promise(T... args)
The Anklang C++ API namespace.
void ase_rethrow(std::exception_ptr exception)
Helper to trace rethrown exceptions.
Start a coroutine in fire-and-forget mode.
T noop_coroutine(T... args)
std::coroutine_handle await_suspend(std::coroutine_handle< promise_type > h)
Resume the parent frame that is co_await-ing this CoTask<>
Like CoTask<Result> without return type.
std::coroutine_handle< promise_type > frame_
Handle for this task.
General purpose coroutine task.
std::coroutine_handle< promise_type > frame_
Handle for this task.