D++ (DPP)  10.0.30
C++ Discord API Bot Library
dpp::detail::async::async_callback_data< R > Struct Template Reference

State of the async and its callback. More...

#include "async.h"

Collaboration diagram for dpp::detail::async::async_callback_data< R >:

Public Member Functions

 ~async_callback_data ()
 Destructor. More...
 
template<typename... Ts>
void construct_result (Ts &&... ts)
 Convenience function to construct the result in the storage and initialize its lifetime. More...
 

Public Attributes

std_coroutine::coroutine_handle coro_handle = nullptr
 Handle to the coroutine co_await-ing on this API call. More...
 
std::atomic< int > ref_count {1}
 Number of references to this callback state. More...
 
std::array< std::byte, sizeof(R)> result_storage
 The stored result of the API call, stored as an array of bytes to directly construct in place. More...
 
std::atomic< state_tstate = state_t::sent
 State of the awaitable and the API callback. More...
 

Detailed Description

template<typename R>
struct dpp::detail::async::async_callback_data< R >

State of the async and its callback.

Defined outside of dpp::async because this seems to work better with Intellisense.

Constructor & Destructor Documentation

◆ ~async_callback_data()

Member Function Documentation

◆ construct_result()

template<typename R >
template<typename... Ts>
void dpp::detail::async::async_callback_data< R >::construct_result ( Ts &&...  ts)
inline

Convenience function to construct the result in the storage and initialize its lifetime.

Warning
This is only a convenience function, ONLY CALL THIS IN THE CALLBACK, before setting state to done.

References dpp::detail::async::async_callback_data< R >::result_storage.

Member Data Documentation

◆ coro_handle

template<typename R >
std_coroutine::coroutine_handle dpp::detail::async::async_callback_data< R >::coro_handle = nullptr

Handle to the coroutine co_await-ing on this API call.

See also
std::coroutine_handle

◆ ref_count

template<typename R >
std::atomic<int> dpp::detail::async::async_callback_data< R >::ref_count {1}

Number of references to this callback state.

◆ result_storage

template<typename R >
std::array<std::byte, sizeof(R)> dpp::detail::async::async_callback_data< R >::result_storage

The stored result of the API call, stored as an array of bytes to directly construct in place.

Referenced by dpp::detail::async::async_callback_data< R >::construct_result(), and dpp::detail::async::async_callback_data< R >::~async_callback_data().

◆ state

template<typename R >
std::atomic<state_t> dpp::detail::async::async_callback_data< R >::state = state_t::sent

State of the awaitable and the API callback.

Referenced by dpp::detail::async::async_callback_data< R >::~async_callback_data().


The documentation for this struct was generated from the following file: