Base class of dpp::async.
More...
#include "async.h"
|
| async_base () noexcept |
| Construct an empty async. More...
|
|
| async_base (async_base &&other) noexcept=default |
| Move constructor. More...
|
|
| async_base (const async_base &)=delete |
| Copy constructor is disabled. More...
|
|
template<typename Fun , typename... Args> |
| async_base (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...
|
|
template<typename Obj , typename Fun , typename... Args> |
| async_base (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...
|
|
| ~async_base () |
| Destructor. More...
|
|
bool | await_ready () const noexcept |
| Check whether or not co_await-ing this would suspend the caller, i.e. More...
|
|
R && | await_resume () &&noexcept |
| Function called by the standard library when the async is resumed. More...
|
|
R & | await_resume () &noexcept |
| Function called by the standard library when the async is resumed. More...
|
|
const R & | await_resume () const &noexcept |
| Function called by the standard library when the async is resumed. More...
|
|
bool | await_suspend (detail::std_coroutine::coroutine_handle<> caller) noexcept |
| Second function called by the standard library when the object is co-awaited, if await_ready returned false. More...
|
|
async_base & | operator= (async_base &&other) noexcept=default |
| Move assignment operator. More...
|
|
async_base & | operator= (const async_base &)=delete |
| Copy assignment is disabled. More...
|
|
template<typename R>
class dpp::detail::async::async_base< R >
Base class of dpp::async.
- Warning
- This class should not be used directly by a user, use dpp::async instead.
- Note
- This class contains all the functions used internally by co_await. It is intentionally opaque and a private base of dpp::async so a user cannot call await_suspend and await_resume directly.
◆ async_base() [1/5]
template<typename R >
template<typename Obj , typename Fun , typename... 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.
- Parameters
-
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 |
◆ async_base() [2/5]
template<typename R >
template<typename Fun , typename... 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.
- Parameters
-
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 |
◆ async_base() [3/5]
Construct an empty async.
Using co_await
on an empty async is undefined behavior.
◆ ~async_base()
Destructor.
If any callback is pending it will be aborted.
◆ async_base() [4/5]
Copy constructor is disabled.
◆ async_base() [5/5]
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.
- Parameters
-
other | The async object to move the data from. |
◆ await_ready()
Check whether or not co_await-ing this would suspend the caller, i.e.
if we have the result or not
- Returns
- bool Whether we already have the result of the API call or not
◆ await_resume() [1/3]
Function called by the standard library when the async is resumed.
Its return value is what the whole co_await expression evaluates to
- Returns
- The result of the API call as an rvalue reference.
◆ await_resume() [2/3]
Function called by the standard library when the async is resumed.
Its return value is what the whole co_await expression evaluates to
- Returns
- The result of the API call as an lvalue reference.
◆ await_resume() [3/3]
Function called by the standard library when the async is resumed.
Its return value is what the whole co_await expression evaluates to
- Returns
- The result of the API call as a const lvalue reference.
◆ await_suspend()
Second function called by the standard library when the object is co-awaited, if await_ready returned false.
Checks again for the presence of the result, if absent, signals to suspend and keep track of the calling coroutine for the callback to resume.
- Parameters
-
caller | The handle to the coroutine co_await-ing and being suspended |
References dpp::detail::async::sent, and dpp::detail::async::waiting.
◆ operator=() [1/2]
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.
- Parameters
-
other | The async object to move the data from |
◆ operator=() [2/2]
Copy assignment is disabled.
The documentation for this class was generated from the following file: