#include <Pt/Coroutine.h>
Provides an awaitable that delivers a result through onReady(). More...
Inherits Awaiter.
Public Member Functions | |
| R | await_resume () |
| Returns the result produced when the awaitable resumes. | |
| bool | await_ready () const |
| Returns false so co_await always suspends. | |
| template<typename P > | |
| bool | await_suspend (std::coroutine_handle< P > h) |
| Starts the operation and suspends the coroutine. | |
| void | cancel () override |
| Cancels the in-flight operation. | |
Protected Member Functions | |
| virtual R | onReady ()=0 |
| Returns the result for the co_await expression. More... | |
| void | setReady () |
| Resumes the waiting coroutine. More... | |
| virtual void | onBegin ()=0 |
| Starts the asynchronous operation. More... | |
| virtual void | onCancel ()=0 |
| Aborts the in-flight operation. More... | |
Use BasicAwaiter instead of Awaiter when the awaitable only needs to produce a value, or to complete with no value. Subclasses still implement Awaiter::onBegin() and Awaiter::onCancel(). Implement BasicAwaiter::onReady() to return the result. The co_await expression is that return value.
BasicAwaiter<void> is the specialization for operations that do not produce a result. Its BasicAwaiter::onReady() returns nothing and can finalize or clean up the operation.
|
protectedpure virtual |
Called exactly once when the coroutine is resumed.
|
protectedinherited |
Call this when the asynchronous operation has completed. Typically connect a completion signal to this method.
|
protectedpure virtualinherited |
Subscribe to completion and begin the work. The coroutine remains suspended until Awaiter::setReady() is called.
Implemented in AsyncYield.
|
protectedpure virtualinherited |
Called from Awaiter::cancel() when the waiting task or generator is cancelled.
Implemented in AsyncYield.