D++ (DPP)
C++ Discord API Bot Library
dpp::detail::task::promise_base< R > Struct Template Reference

Base implementation of task::promise_t, without the logic that would depend on the return type. Meant to be inherited from. More...

+ Inheritance diagram for dpp::detail::task::promise_base< R >:
+ Collaboration diagram for dpp::detail::task::promise_base< R >:

Classes

struct  proxy_awaiter
 Proxy awaitable that wraps any co_await inside the task and checks for cancellation on resumption. More...
 

Public Member Functions

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<typename 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...
 

Public Attributes

std::atomic< boolcancelled = false
 Whether the task is cancelled or not. More...
 

Detailed Description

template<typename R>
struct dpp::detail::task::promise_base< R >

Base implementation of task::promise_t, without the logic that would depend on the return type. Meant to be inherited from.

Member Function Documentation

◆ await_transform()

template<typename R >
template<typename T >
auto dpp::detail::task::promise_base< R >::await_transform ( T &&  expr) const
inlinenoexcept

Function called whenever co_await is used inside of the task.

Exceptions
dpp::task_cancelled_exceptionOn resumption if the task was cancelled
Returns
proxy_awaiter Returns a proxy awaiter that will check for cancellation on resumption

◆ initial_suspend()

template<typename R >
std_coroutine::suspend_never dpp::detail::task::promise_base< R >::initial_suspend ( ) const
inlinenoexcept

Function called by the standard library when the coroutine is created.

Returns
std::suspend_never Don't suspend, the coroutine starts immediately.

◆ unhandled_exception()

template<typename R >
void dpp::detail::task::promise_base< R >::unhandled_exception ( )
inline

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

Member Data Documentation

◆ cancelled

template<typename R >
std::atomic<bool> dpp::detail::task::promise_base< R >::cancelled = false

Whether the task is cancelled or not.

D++ Library version 9.0.13D++ Library version 9.0.12D++ Library version 9.0.11D++ Library version 9.0.10D++ Library version 9.0.9D++ Library version 9.0.8D++ Library version 9.0.7D++ Library version 9.0.6D++ Library version 9.0.5D++ Library version 9.0.4D++ Library version 9.0.3D++ Library version 9.0.2D++ Library version 9.0.1D++ Library version 9.0.0D++ Library version 1.0.2D++ Library version 1.0.1D++ Library version 1.0.0