|
fiber
|
Owning handle to a coroutine with a custom promise type. More...
#include <Coroutine.hpp>
Public Types | |
| using | promise_type = CoroutinePromise<ReturnType> |
| using | promise_handle = std::coroutine_handle<promise_type> |
Public Member Functions | |
| constexpr | Coroutine ()=default |
| constexpr | Coroutine (promise_handle &&h) |
| constexpr | Coroutine (const Coroutine &)=delete |
| constexpr Coroutine & | operator= (const Coroutine &)=delete |
| constexpr | Coroutine (Coroutine &&other) noexcept |
| constexpr Coroutine & | operator= (Coroutine &&other) noexcept |
| constexpr | ~Coroutine () noexcept |
| constexpr void | resume () |
| constexpr void | destroy () |
| constexpr void | Register (TaskBase *task) |
| constexpr bool | is_done () const |
| constexpr | operator bool () const noexcept |
| constexpr CoroutinePromise< ReturnType > & | promise () |
| constexpr CoroutineNode * | node () |
| constexpr const CoroutineNode * | node () const |
| constexpr bool | await_ready () const noexcept |
| template<class T> | |
| constexpr void | await_suspend (std::coroutine_handle< CoroutinePromise< T > > handle) noexcept |
| constexpr ReturnType | await_resume () |
| constexpr void | await_resume () |
Public Attributes | |
| promise_handle | coro = nullptr |
Owning handle to a coroutine with a custom promise type.
This class represents a coroutine that yields a result of type ReturnType via co_return. It provides mechanisms to manage coroutine execution and lifecycle, including resuming execution, checking completion, and accessing the coroutine's internal promise object. It wraps a coroutine handle (std::coroutine_handle<CoroutinePromise<ReturnType>>) and owns its and the associated promise types (CoroutinePromise<ReturnType>) lifetime.
This type implements the awaiter interface, enabling it to be co_await-ed inside other coroutines (nested coroutines). The methods await_ready, await_suspend, and await_resume define the suspension behavior:
await_ready() checks if the coroutine has already completed.await_suspend() suspends the caller until this coroutine completes.await_resume() retrieves the result from the coroutine.| ReturnType | The type returned from the coroutine using co_return. If void, the coroutine does not produce a result. |
| using fiber::Coroutine< ReturnType >::promise_handle = std::coroutine_handle<promise_type> |
| using fiber::Coroutine< ReturnType >::promise_type = CoroutinePromise<ReturnType> |
|
constexprdefault |
|
inlineexplicitconstexpr |
|
constexprdelete |
|
inlineconstexprnoexcept |
|
constexprnoexcept |
|
constexprnoexcept |
|
constexpr |
|
constexpr |
|
constexprnoexcept |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
|
explicitconstexprnoexcept |
|
constexprdelete |
|
inlineconstexprnoexcept |
|
constexpr |
|
constexpr |
|
constexpr |
| promise_handle fiber::Coroutine< ReturnType >::coro = nullptr |