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

Awaitable object representing an event. More...

#include "event_router.h"

Public Member Functions

 awaitable (awaitable &&rhs) noexcept
 Move constructor. More...
 
 awaitable (const awaitable &)=delete
 This object is not copyable. More...
 
constexpr bool await_ready () const noexcept
 First function called by the standard library when awaiting this object. More...
 
const T & await_resume ()
 Third and final function called by the standard library, called when resuming the coroutine. More...
 
void await_suspend (detail::std_coroutine::coroutine_handle<> caller)
 Second function called by the standard library when awaiting this object, after suspension. More...
 
void cancel ()
 Request cancellation. More...
 
awaitableoperator= (awaitable &&rhs) noexcept
 Move assignment operator. More...
 
awaitableoperator= (const awaitable &)=delete
 This object is not copyable. 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

The documentation for this class was generated from the following files: