|
uvco 0.1
|
#include <multipromise.h>


Public Member Functions | |
| MultiPromiseCore ()=default | |
| MultiPromiseCore (const MultiPromiseCore &)=delete | |
| MultiPromiseCore (MultiPromiseCore &&)=delete | |
| MultiPromiseCore & | operator= (const MultiPromiseCore &)=delete |
| MultiPromiseCore & | operator= (MultiPromiseCore &&)=delete |
| ~MultiPromiseCore () override=default | |
| void | setHandle (std::coroutine_handle<> handle) override |
| void | resumeGenerator () |
| void | suspendGenerator () |
| void | cancelGenerator () |
| void | setTerminated () |
| bool | isTerminated () const |
| Check if the generator has been cancelled or has returned. | |
| Public Member Functions inherited from uvco::PromiseCore< T > | |
| PromiseCore ()=default | |
| PromiseCore (const PromiseCore &)=delete | |
| PromiseCore (PromiseCore &&)=delete | |
| PromiseCore & | operator= (const PromiseCore &)=delete |
| PromiseCore & | operator= (PromiseCore &&)=delete |
| virtual | ~PromiseCore ()=default |
| PromiseCore (T &&value) | |
| void | setRunning (std::coroutine_handle<> handle) |
| Used by Coroutine<T> to set the producing coroutine handle. | |
| void | resetHandle () |
| bool | isAwaited () |
| Checks if a coroutine is waiting on a promise belonging to this core. | |
| bool | ready () const |
| Checks if a value is present in the slot. | |
| bool | stale () const |
| void | resume () |
| void | destroyCoroutine () |
| void | except (const std::exception_ptr &exc) |
Private Attributes | |
| bool | suspended_ = false |
| True if the generator is suspended at a co_yield point. | |
| bool | terminated_ = false |
Additional Inherited Members | |
| Public Attributes inherited from uvco::PromiseCore< T > | |
| std::optional< std::variant< T, std::exception_ptr > > | slot |
| The slot contains the result once obtained. | |
| Protected Attributes inherited from uvco::PromiseCore< T > | |
| std::coroutine_handle | coroutine_ |
| std::coroutine_handle | waitingHandle_ |
| PromiseState | state_ = PromiseState::init |
A MultiPromiseCore works like a PromiseCore, but with an adapted state machine: it can transition from finished back to waitedOn, and therefore yield more than one value. It is used by MultiPromise, a generator-like type.
|
default |
|
delete |
|
delete |
|
overridedefault |
|
inline |
Cancel the generator coroutine. This will drop all stack variables inside the generator (and run their destructors), and ensure that the generatorHandle_ will never resume from the currently yielded value.
Called by tje MultiPromise destructor and MultiPromise::cancel().
|
inlinenodiscard |
Check if the generator has been cancelled or has returned.
|
delete |
|
delete |
|
inline |
Resume the generator from its last co_yield point, so it can yield the next value.
Called by a MultiPromiseAwaiter_ when the MultiPromise is co_awaited, after a value has been successfully awaited.
|
inlineoverridevirtual |
See PromiseCore::setHandle. Called by a MultiPromise when it is co_awaited.
In contrast to a PromiseCore, a finished multipromise core can be reset to the waiting state, in order to yield the next value, when the MultiPromise is co_awaited again.
Reimplemented from uvco::PromiseCore< T >.
|
inline |
Mark generator as finished, yielding no more values. Called from within the MultiPromise upon return_value and unhandled_exception. From hereon awaiting the generator will either rethrow the thrown exception, or yield nullopt.
|
inline |
Suspend the generator coroutine at the current co_yield point by storing the handle for a later resumption.
Called by the MultiPromise<...>::yield_value method when co_yield is invoked inside the generator.
|
private |
True if the generator is suspended at a co_yield point.
|
private |
Set to true once the generator coroutine has returned or has been cancelled.