D++ (DPP)
C++ Discord API Bot Library
|
A co_await-able object handling an API call in parallel with the caller. 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 () noexcept | |
Construct an empty async. Using co_await on an empty async is undefined behavior. More... | |
~async () | |
Destructor. If any callback is pending it will be aborted. More... | |
async (const async &) | |
Copy constructor is disabled. More... | |
async (async &&other) noexcept=default | |
Move constructor. More... | |
async & | operator= (const async &)=delete |
Copy assignment is disabled. More... | |
async & | operator= (async &&other) noexcept=default |
Move assignment operator. More... | |
bool | await_ready () const noexcept |
Check whether or not co_await-ing this would suspend the caller, i.e. if we have the result or not. More... | |
auto & | operator co_await () &noexcept |
Suspend the caller until the request completes. More... | |
const auto & | operator co_await () const &noexcept |
Suspend the caller until the request completes. More... | |
auto && | operator co_await () &&noexcept |
Suspend the caller until the request completes. More... | |
Friends | |
class | detail::async::async_base< R > |
Internal use only base class. It serves to prevent await_suspend and await_resume from being used directly. 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 |
|
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 |
|
noexcept |
Construct an empty async. Using co_await
on an empty async is undefined behavior.
dpp::async< R >::~async | ( | ) |
Destructor. If any callback is pending it will be aborted.
dpp::async< R >::async | ( | const async< R > & | ) |
Copy constructor is disabled.
|
defaultnoexcept |
Move constructor.
NOTE: Despite being marked noexcept, this function uses std::lock_guard which may throw. The implementation assumes this can never happen, hence noexcept. Report it if it does, as that would be a bug.
other | The async object to move the data from. |
|
noexcept |
Check whether or not co_await-ing this would suspend the caller, i.e. if we have the result or not.
|
inlinenoexcept |
Suspend the caller until the request completes.
|
inlinenoexcept |
Suspend the caller until the request completes.
|
inlinenoexcept |
Suspend the caller until the request completes.
|
defaultnoexcept |
Move assignment operator.
NOTE: Despite being marked noexcept, this function uses std::lock_guard which may throw. The implementation assumes this can never happen, hence noexcept. Report it if it does, as that would be a bug.
other | The async object to move the data from |
|
delete |
Copy assignment is disabled.
|
friend |
Internal use only base class. It serves to prevent await_suspend and await_resume from being used directly.