D++ (DPP)
C++ Discord API Bot Library
|
Base class defining logic common to all promise types, aka the "write" end of an awaitable. More...
#include <awaitable.h>
Public Member Functions | |
promise_base & | operator= (const promise_base &)=delete |
Copy assignment is disabled. More... | |
promise_base & | operator= (promise_base &&rhs)=delete |
Move assignment is disabled. More... | |
template<bool Notify = true> | |
void | set_exception (std::exception_ptr ptr) |
Set this promise to an exception and resume any awaiter. More... | |
void | notify_awaiter () |
Notify a currently awaiting coroutine that the result is ready. More... | |
awaitable< T > | get_awaitable () |
Get an awaitable object for this promise. More... | |
Protected Types | |
using | storage_type = result_t< T > |
Variant representing one of either 3 states of the result value : empty, result, exception. More... | |
Protected Member Functions | |
void | throw_if_not_empty () |
Check if the result is empty, throws otherwise. More... | |
std_coroutine::coroutine_handle | release_awaiter () |
Unlinks this promise from its currently linked awaiter and returns it. More... | |
promise_base ()=default | |
Construct a new promise, with empty result. More... | |
promise_base (const promise_base &)=delete | |
Copy construction is disabled. More... | |
promise_base (promise_base &&rhs)=delete | |
Move construction is disabled. More... | |
Protected Attributes | |
storage_type | value = std::monostate{} |
State of the result value. More... | |
std::atomic< uint8_t > | state = sf_none |
State of the awaitable tied to this promise. More... | |
std_coroutine::coroutine_handle | awaiter = nullptr |
Coroutine handle currently awaiting the completion of this promise. More... | |
Friends | |
class | awaitable< T > |
Base class defining logic common to all promise types, aka the "write" end of an awaitable.
|
protected |
Variant representing one of either 3 states of the result value : empty, result, exception.
|
protecteddefault |
Construct a new promise, with empty result.
|
protecteddelete |
Copy construction is disabled.
|
protecteddelete |
Move construction is disabled.
awaitable hold a pointer to this object so moving is not possible.
|
inline |
Get an awaitable object for this promise.
dpp::logic_exception | if get_awaitable has already been called on this object. |
|
inline |
Notify a currently awaiting coroutine that the result is ready.
? | Any exception thrown by the coroutine if resumed will propagate |
|
delete |
Copy assignment is disabled.
|
delete |
Move assignment is disabled.
|
inlineprotected |
Unlinks this promise from its currently linked awaiter and returns it.
At the time of writing this is only used in the case of a serious internal error in dpp::task. Avoid using this as this will crash if the promise is used after this.
|
inline |
Set this promise to an exception and resume any awaiter.
Notify | Whether to resume any awaiter or not. |
dpp::logic_exception | if the promise is not empty. |
? | Any exception thrown by the coroutine if resumed will propagate |
|
inlineprotected |
Check if the result is empty, throws otherwise.
dpp::logic_exception | if the result isn't empty. |
|
friend |
|
protected |
Coroutine handle currently awaiting the completion of this promise.
|
protected |
State of the awaitable tied to this promise.
|
protected |
State of the result value.