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

#include <event_router.h>

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

ref task_cancelled_exception if cancel() has been called

Returns
const T& Reference to the event that matched

◆ 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 10.0.29D++ Library version 10.0.28D++ Library version 10.0.27D++ Library version 10.0.26D++ Library version 10.0.25D++ Library version 10.0.24D++ Library version 10.0.23D++ Library version 10.0.22D++ Library version 10.0.21D++ Library version 10.0.20D++ Library version 10.0.19D++ Library version 10.0.18D++ Library version 10.0.17D++ Library version 10.0.16D++ Library version 10.0.15D++ Library version 10.0.14D++ Library version 10.0.13D++ Library version 10.0.12D++ Library version 10.0.11D++ Library version 10.0.10D++ Library version 10.0.9D++ Library version 10.0.8D++ Library version 10.0.7D++ Library version 10.0.6D++ Library version 10.0.5D++ Library version 10.0.4D++ Library version 10.0.3D++ Library version 10.0.2D++ Library version 10.0.1D++ Library version 10.0.0D++ Library version 9.0.19D++ Library version 9.0.18D++ Library version 9.0.17D++ Library version 9.0.16D++ Library version 9.0.15D++ Library version 9.0.14D++ 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