D++ (DPP)
C++ Discord API Bot Library
|
A task's promise_t type, with special logic for handling nested tasks. More...
#include <task.h>
Public Member Functions | |
void | return_value (R &&expr) noexcept(std::is_nothrow_move_constructible_v< R >) |
Function called by the standard library when the coroutine co_returns a value. More... | |
void | return_value (const R &expr) noexcept(std::is_nothrow_copy_constructible_v< R >) |
Function called by the standard library when the coroutine co_returns a value. More... | |
template<typename T > requires (!std::is_same_v<R, std::remove_cvref_t<T>> && std::convertible_to<T, R>) | |
void | return_value (T &&expr) noexcept(std::is_nothrow_convertible_v< T, R >) |
Function called by the standard library when the coroutine co_returns a value. More... | |
dpp::task< R > | get_return_object () noexcept |
Function called by the standard library when the coroutine is created. More... | |
final_awaiter< R > | final_suspend () const noexcept |
Function called by the standard library when the coroutine reaches its last suspension point. More... | |
std_coroutine::suspend_never | initial_suspend () const noexcept |
Function called by the standard library when the coroutine is created. More... | |
void | unhandled_exception () |
Function called by the standard library when an exception is thrown and not caught in the coroutine. More... | |
template<awaitable_type T> | |
auto | await_transform (T &&expr) const noexcept(noexcept(co_await_resolve(std::forward< T >(expr)))) |
Function called whenever co_await is used inside of the task. More... | |
void | emplace_value (Args &&... args) |
Construct the result in place by forwarding the arguments, and by default resume any awaiter. More... | |
void | set_value (U &&v) |
Construct the result by forwarding reference, and resume any awaiter. More... | |
void | set_value () |
Construct a void result, and resume any awaiter. 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... | |
Public Attributes | |
std::atomic< bool > | cancelled = false |
Whether the task is cancelled or not. 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... | |
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 | |
struct | final_awaiter< R > |
A task's promise_t type, with special logic for handling nested tasks.
Implementation of task::promise_t for non-void return type.
R | Return type of the task |
|
protectedinherited |
Variant representing one of either 3 states of the result value : empty, result, exception.
|
inlinenoexceptinherited |
Function called whenever co_await is used inside of the task.
dpp::task_cancelled_exception | On resumption if the task was cancelled |
|
inlineinherited |
Construct the result in place by forwarding the arguments, and by default resume any awaiter.
Notify | Whether to resume any awaiter or not. |
dpp::logic_exception | if the promise is not empty. |
|
inlinenoexcept |
Function called by the standard library when the coroutine reaches its last suspension point.
|
inlineinherited |
Get an awaitable object for this promise.
dpp::logic_exception | if get_awaitable has already been called on this object. |
|
inlinenoexcept |
Function called by the standard library when the coroutine is created.
|
inlinenoexceptinherited |
Function called by the standard library when the coroutine is created.
|
inlineinherited |
Notify a currently awaiting coroutine that the result is ready.
? | Any exception thrown by the coroutine if resumed will propagate |
|
inlineprotectedinherited |
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.
|
inlinenoexcept |
Function called by the standard library when the coroutine co_returns a value.
Stores the value internally to hand to the caller when it resumes.
expr | The value given to co_return |
|
inlinenoexcept |
Function called by the standard library when the coroutine co_returns a value.
Stores the value internally to hand to the caller when it resumes.
expr | The value given to co_return |
|
inlinenoexcept |
Function called by the standard library when the coroutine co_returns a value.
Stores the value internally to hand to the caller when it resumes.
expr | The value given to co_return |
|
inlineinherited |
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 |
|
inlineinherited |
Construct a void result, and resume any awaiter.
Notify | Whether to resume any awaiter or not. |
dpp::logic_exception | if the promise is not empty. |
|
inlineinherited |
Construct the result by forwarding reference, and resume any awaiter.
Notify | Whether to resume any awaiter or not. |
dpp::logic_exception | if the promise is not empty. |
|
inlineprotectedinherited |
Check if the result is empty, throws otherwise.
dpp::logic_exception | if the result isn't empty. |
|
inlineinherited |
Function called by the standard library when an exception is thrown and not caught in the coroutine.
Stores the exception pointer to rethrow on co_await. If the task object is destroyed and was not cancelled, throw instead
|
friend |
|
protectedinherited |
Coroutine handle currently awaiting the completion of this promise.
|
inherited |
Whether the task is cancelled or not.
|
protectedinherited |
State of the awaitable tied to this promise.
|
protectedinherited |
State of the result value.