D++ (DPP)
C++ Discord API Bot Library
|
A co_await-able object handling an API call in parallel with the caller. More...
#include <coro/async.h>
Public Types | |
using | result_type = R |
The return type of the API call. Defaults to confirmation_callback_t. More... | |
Public Member Functions | |
template<typename Obj , typename Fun , typename... Args> | |
async (Obj &&obj, Fun &&fun, Args &&... args) | |
Construct an async object wrapping an object method, the call is made immediately by forwarding to std::invoke and can be awaited later to retrieve the result. More... | |
template<typename Fun , typename... Args> | |
async (Fun &&fun, Args &&... args) | |
Construct an async object wrapping an invokeable object, the call is made immediately by forwarding to std::invoke and can be awaited later to retrieve the result. More... | |
async (const async &)=delete | |
Copy constructor is disabled. More... | |
async (async &&)=default | |
Move constructor, moves the awaitable async object. More... | |
async & | operator= (const async &)=delete |
Copy assignment operator is disabled. More... | |
async & | operator= (async &&)=default |
Move assignment operator, moves the awaitable async object. More... | |
~async () | |
Destructor, signals to the callback that the async object is gone and shouldn't be notified of the result. More... | |
void | if_this_causes_an_invalid_read_your_promise_was_destroyed_before_your_awaitable____check_your_promise_lifetime () |
Title :) More... | |
bool | valid () const noexcept |
Check whether this awaitable refers to a valid promise. More... | |
bool | await_ready () const |
Check whether or not co_await-ing this would suspend the caller, i.e. if we have the result or not. More... | |
auto | sync_wait () |
Blocks this thread and waits for the awaitable to finish. More... | |
auto | sync_wait_for (const std::chrono::duration< Rep, Period > &duration) |
Blocks this thread and waits for the awaitable to finish. More... | |
auto | sync_wait_until (const std::chrono::time_point< Clock, Duration > &time) |
Blocks this thread and waits for the awaitable to finish. More... | |
Protected Types | |
using | shared_state = detail::promise::promise_base< R > |
using | state_flags = detail::promise::state_flags |
Protected Member Functions | |
uint8_t | abandon () |
Abandons the promise. More... | |
auto | sync_wait_impl (auto &&do_wait) |
Implementation for sync_wait. This is code used by sync_wait, sync_wait_for, sync_wait_until. More... | |
Protected Attributes | |
shared_state * | state_ptr |
Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable. More... | |
A co_await-able object handling an API call in parallel with the caller.
This class is the return type of the dpp::cluster::co_* methods, but it can also be created manually to wrap any async call.
R | The return type of the API call. Defaults to confirmation_callback_t |
using dpp::async< R >::result_type = R |
The return type of the API call. Defaults to confirmation_callback_t.
|
protectedinherited |
|
protectedinherited |
|
inlineexplicit |
Construct an async object wrapping an object method, the call is made immediately by forwarding to std::invoke and can be awaited later to retrieve the result.
obj | The object to call the method on |
fun | The method of the object to call. Its last parameter must be a callback taking a parameter of type R |
args | Parameters to pass to the method, excluding the callback |
|
inlineexplicit |
Construct an async object wrapping an invokeable object, the call is made immediately by forwarding to std::invoke and can be awaited later to retrieve the result.
fun | The object to call using std::invoke. Its last parameter must be a callable taking a parameter of type R |
args | Parameters to pass to the object, excluding the callback |
|
delete |
Copy constructor is disabled.
|
default |
Move constructor, moves the awaitable async object.
|
inline |
Destructor, signals to the callback that the async object is gone and shouldn't be notified of the result.
|
protectedinherited |
Abandons the promise.
Set the promise's state to broken and unlinks this awaitable.
|
inherited |
Check whether or not co_await-ing this would suspend the caller, i.e. if we have the result or not.
|
inlineinherited |
Title :)
We use this in the destructor
|
default |
Move assignment operator, moves the awaitable async object.
|
delete |
Copy assignment operator is disabled.
|
inlineinherited |
Blocks this thread and waits for the awaitable to finish.
|
inlineinherited |
Blocks this thread and waits for the awaitable to finish.
duration | Maximum duration to wait for |
|
inlineprotectedinherited |
Implementation for sync_wait. This is code used by sync_wait, sync_wait_for, sync_wait_until.
Timed | Whether the wait function times out or not |
do_wait | Function to do the actual wait on the cv |
|
inlineinherited |
Blocks this thread and waits for the awaitable to finish.
time | Maximum time point to wait for |
|
noexceptinherited |
Check whether this awaitable refers to a valid promise.
|
protectedinherited |
Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable.