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

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

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

Public Member Functions

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

Public Attributes

std::atomic< int > ref_count {1}
 Number of references to this callback state. More...
 
std::atomic< state_tstate = state_t::sent
 State of the awaitable and the API callback. 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_coroutine::coroutine_handle coro_handle = nullptr
 Handle to the coroutine co_await-ing on this API call. 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()

template<typename R >
dpp::detail::async::async_callback_data< R >::~async_callback_data ( )
inline

Destructor.

Also destroys the result if present.

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.

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.

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

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