D++ (DPP)
C++ Discord API Bot Library
dpp::detail::event_router::awaitable< T > Class Template Reference

Awaitable object representing an event. A user can co_await on this object to resume the next time the event is fired, optionally with a condition. More...

+ Inheritance diagram for dpp::detail::event_router::awaitable< T >:

Public Member Functions

 awaitable (const awaitable &)=delete
 
 awaitable (awaitable &&rhs) noexcept
 
awaitableoperator= (const awaitable &)=delete
 
awaitableoperator= (awaitable &&rhs) noexcept
 
void cancel ()
 Request cancellation. This will detach this object from the event router and resume the awaiter, which will be thrown dpp::task_cancelled::exception. More...
 
constexpr bool await_ready () const noexcept
 First function called by the standard library when awaiting this object. Returns true if we need to suspend. More...
 
void await_suspend (detail::std_coroutine::coroutine_handle<> caller)
 Second function called by the standard library when awaiting this object, after suspension. This will attach the object to its event router, to be resumed on the next event that satisfies the predicate. More...
 
const T & await_resume ()
 Third and final function called by the standard library, called when resuming the coroutine. More...
 

Friends

class event_router_t< T >
 

Detailed Description

template<typename T>
class dpp::detail::event_router::awaitable< T >

Awaitable object representing an event. A user can co_await on this object to resume the next time the event is fired, optionally with a condition.

Constructor & Destructor Documentation

◆ awaitable() [1/2]

template<typename T >
dpp::detail::event_router::awaitable< T >::awaitable ( const awaitable< T > &  )
delete

This object is not copyable.

◆ awaitable() [2/2]

template<typename T >
dpp::detail::event_router::awaitable< T >::awaitable ( awaitable< T > &&  rhs)
inlinenoexcept

Move constructor.

Member Function Documentation

◆ await_ready()

template<typename T >
constexpr bool dpp::detail::event_router::awaitable< T >::await_ready
constexprnoexcept

First function called by the standard library when awaiting this object. Returns true if we need to suspend.

Return values
falsealways.

◆ await_resume()

template<typename T >
const T & dpp::detail::event_router::awaitable< T >::await_resume

Third and final function called by the standard library, called when resuming the coroutine.

Exceptions

◆ await_suspend()

template<typename T >
void dpp::detail::event_router::awaitable< T >::await_suspend ( detail::std_coroutine::coroutine_handle<>  caller)

Second function called by the standard library when awaiting this object, after suspension. This will attach the object to its event router, to be resumed on the next event that satisfies the predicate.

Returns
void never resume on call.

◆ cancel()

template<typename T >
void dpp::detail::event_router::awaitable< T >::cancel

Request cancellation. This will detach this object from the event router and resume the awaiter, which will be thrown dpp::task_cancelled::exception.

Exceptions
???As this resumes the coroutine, it may throw any exceptions at the caller.

If state == none (was never awaited), do nothing If state == waiting, prevent resumption, resume on our end If state == resuming || cancelling, ignore

◆ operator=() [1/2]

template<typename T >
awaitable& dpp::detail::event_router::awaitable< T >::operator= ( awaitable< T > &&  rhs)
inlinenoexcept

Move assignment operator.

◆ operator=() [2/2]

template<typename T >
awaitable& dpp::detail::event_router::awaitable< T >::operator= ( const awaitable< T > &  )
delete

This object is not copyable.

Friends And Related Function Documentation

◆ event_router_t< T >

template<typename T >
friend class event_router_t< T >
friend
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