| D++ (DPP) C++ Discord API Bot Library

Search
Loading...
Searching...
No Matches
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>`

Inheritance diagram for dpp::detail::event_router::awaitable< T >:
[legend]

## Public Member Functions

| awaitable (awaitable &&rhs) noexcept
| awaitable (const awaitable &)=delete
constexpr bool | await_ready () const noexcept
| First function called by the standard library when awaiting this object. Returns true if we need to suspend.
const T & | await_resume ()
| Third and final function called by the standard library, called when resuming the coroutine.
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.
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.
awaitable & | operator= (awaitable &&rhs) noexcept
awaitable & | operator= (const awaitable &)=delete

## 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 | ) |

inline noexcept

Move constructor.

## Member Function Documentation

## ◆ await_ready()

template<typename T>

bool dpp::detail::event_router::awaitable< T >::await_ready | ( |  | ) | const

nodiscard constexpr noexcept

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

Return values

  false | always.

## ◆ 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 | ) |

inline noexcept

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 Symbol Documentation

## ◆ event_router_t< T >

template<typename T>

friend class event_router_t< T >

friend

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