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

A co_await-able struct which returns the result of stored api call when co_await-ed. Meant to be opaque to the user. More...

#include <coro.h>

+ Collaboration diagram for dpp::awaitable< T >:

Public Member Functions

 awaitable (cluster *cl, T api_call)
 Construct a new awaitable object. More...
 
bool await_ready () noexcept
 First function called when this object is co_await-ed, its return type tells if the coroutine should be immediately suspended. More...
 
void await_suspend (handle_type handle)
 Function called when the coroutine is suspended, makes the api request and queues the resumption of the suspended coroutine, storing the result in promise object. More...
 
confirmation_callback_t await_resume ()
 Function called when the coroutine is resumed by its handle, handles the retrieval and return of result from promise object. More...
 

Public Attributes

promisep
 Pointer to the nested promise object of the coroutine, used for storing and retrieving the result of an api call. More...
 
clusterbot
 Pointer to the cluster making the api request. More...
 
api_req
 The function handling the making of request, using the cluster pointer. More...
 

Detailed Description

template<typename T>
struct dpp::awaitable< T >

A co_await-able struct which returns the result of stored api call when co_await-ed. Meant to be opaque to the user.

Template Parameters
TThe type of the function (lambda if auto-generated by the php script) handling the making of api call

Constructor & Destructor Documentation

◆ awaitable()

template<typename T >
dpp::awaitable< T >::awaitable ( cluster cl,
api_call 
)
inline

Construct a new awaitable object.

Parameters
clpointer to the cluster making the api request
api_calla function to invoke with the cluster pointer, handles the making of request

Member Function Documentation

◆ await_ready()

template<typename T >
bool dpp::awaitable< T >::await_ready ( )
inlinenoexcept

First function called when this object is co_await-ed, its return type tells if the coroutine should be immediately suspended.

Returns
bool false, signifying immediate suspension

◆ await_resume()

template<typename T >
confirmation_callback_t dpp::awaitable< T >::await_resume ( )
inline

Function called when the coroutine is resumed by its handle, handles the retrieval and return of result from promise object.

Returns
confirmation_callback_t the result of the api call

◆ await_suspend()

template<typename T >
void dpp::awaitable< T >::await_suspend ( handle_type  handle)
inline

Function called when the coroutine is suspended, makes the api request and queues the resumption of the suspended coroutine, storing the result in promise object.

Parameters
handlethe handle to the suspended coroutine

Member Data Documentation

◆ api_req

template<typename T >
T dpp::awaitable< T >::api_req

The function handling the making of request, using the cluster pointer.

◆ bot

template<typename T >
cluster* dpp::awaitable< T >::bot

Pointer to the cluster making the api request.

◆ p

template<typename T >
promise* dpp::awaitable< T >::p

Pointer to the nested promise object of the coroutine, used for storing and retrieving the result of an api call.

D++ 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