|
uvco 0.1
|
#include <promise.h>
Public Member Functions | |
| template<typename... Args> | |
| Coroutine (Args &&...) | |
| Coroutine ()=default | |
| Coroutine (const Coroutine &other)=delete | |
| Coroutine & | operator= (const Coroutine &other)=delete |
| Coroutine (Coroutine &&other)=delete | |
| Coroutine & | operator= (Coroutine &&other)=delete |
| ~Coroutine ()=default | |
| Promise< T > | get_return_object () |
| void | return_value (T value) |
| std::suspend_never | initial_suspend () noexcept |
| std::suspend_always | final_suspend () noexcept |
| void | unhandled_exception () |
Protected Attributes | |
| PromiseCore< T > | core_ |
Private Types | |
| using | PromiseCore_ = PromiseCore<T> |
| PromiseCore_ handles the inner mechanics of resumption and suspension. | |
| using | SharedCore_ = PromiseCore_ * |
A coroutine object used internally by C++20 coroutines ("promise object"). This is the coroutine's "promise_type", i.e. one instance will be allocated for every coroutine invocation, and be part of the coroutine frame. The coroutine frame will be stack-allocated if we're lucky.
|
private |
PromiseCore_ handles the inner mechanics of resumption and suspension.
|
private |
|
inlineexplicit |
This construct forbids coroutines taking rvalue/xvalue arguments, which often enough come from function return values. If a Promise returned by such a coroutine is stored and awaited later, a use-after-free or use-after-return results.
Instead, pass arguments by lvalue reference (which forbids xvalues), or by value (which allows xvalues, and is safe).
The typical violating example is as follows:
|
default |
Coroutine object lives and is pinned within the coroutine frame; copy/move is disallowed.
|
delete |
|
delete |
|
default |
|
inlinenoexcept |
Part of the coroutine protocol: called upon co_return or unhandled exception.
|
inline |
Part of the coroutine protocol: Called on first suspension point (co_await) or co_return.
|
inlinenoexcept |
Part of the coroutine protocol: called after construction of Promise object, i.e. before starting the coroutine.
In uvco, the coroutine always runs at least up to its first suspension point, at which point it may be suspended (if the awaited object is not ready).
|
delete |
|
delete |
|
inline |
Part of the coroutine protocol: Called by co_return. Schedules the awaiting coroutine for resumption.
|
inline |
|
protected |