async_function
A function can mark itself as a coroutine by having a return type of async_function
.
The promise type for an async_function
must satisfy the Execution
concept. The default promise type is the execution_promise.
async_function<>
foo() noexcept
{
/* async behaviour goes here... */
}
-
template<details::Execution PromiseType = execution_promise>
class zab::async_function This class describes an asynchronous function.
This classed should only be used as the return type of a function to enable coroutines. It should never be stored and only kept as a tempory object.
For example: ``` auto foo() -> async_function { async behaviour };
void bar() { … foo(); … }
Public Types
-
using promise_type = PromiseType
-
using coro_handle = std::coroutine_handle<promise_type>
Public Functions
-
inline async_function(coro_handle)
Constructor no-ops.
- Parameters
<unnamed> – [in]
-
~async_function() = default
Default clean this object up.
-
async_function(const async_function&) = delete
Deleted copy constructor.
- Parameters
<unnamed> – [in]
-
async_function(async_function&&) = delete
Deleted move constructor.
- Parameters
<unnamed> – [in]
-
async_function &operator=(const async_function&) = delete
Deleted Assignment operator.
- Parameters
<unnamed> – [in]
- Returns
this
-
using promise_type = PromiseType