D++ (DPP)
C++ Discord API Bot Library
|
Generic awaitable class, represents a future value that can be co_await-ed on. More...
#include <awaitable.h>
Classes | |
struct | awaiter |
Awaiter returned by co_await. More... | |
Public Member Functions | |
awaitable ()=default | |
Construct an empty awaitable. More... | |
awaitable (const awaitable &)=delete | |
Copy construction is disabled. More... | |
awaitable (awaitable &&rhs) noexcept | |
Move from another awaitable. More... | |
void | if_this_causes_an_invalid_read_your_promise_was_destroyed_before_your_awaitable____check_your_promise_lifetime () |
Title :) More... | |
~awaitable () | |
Destructor. More... | |
awaitable & | operator= (const awaitable &)=delete |
Copy assignment is disabled. More... | |
awaitable & | operator= (awaitable &&rhs) noexcept |
Move from another awaitable. 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< T > |
using | state_flags = detail::promise::state_flags |
using | result_type = T |
The type of the result produced by this task. More... | |
Protected Member Functions | |
awaitable (shared_state *promise) noexcept | |
Construct from a promise. More... | |
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 = nullptr |
Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable. More... | |
Friends | |
class | detail::promise::promise_base< T > |
template<typename Derived > requires (std::is_base_of_v<awaitable, std::remove_cv_t<Derived>>) | |
awaiter< Derived & > | operator co_await (Derived &obj) noexcept |
Overload of the co_await operator. More... | |
template<typename Derived > requires (std::is_base_of_v<awaitable, std::remove_cv_t<Derived>>) | |
awaiter< Derived && > | operator co_await (Derived &&obj) noexcept |
Overload of the co_await operator. Returns an awaiter referencing this awaitable. More... | |
Generic awaitable class, represents a future value that can be co_await-ed on.
Roughly equivalent of std::future for coroutines, with the crucial distinction that the future does not own a reference to a "shared state". It holds a non-owning reference to the promise, which must be kept alive for the entire lifetime of the awaitable.
T | Type of the asynchronous value |
|
protected |
The type of the result produced by this task.
|
protected |
|
protected |
|
inlineprotectednoexcept |
Construct from a promise.
promise | The promise to refer to. |
|
default |
Construct an empty awaitable.
Such an awaitable must be assigned a promise before it can be awaited.
|
delete |
Copy construction is disabled.
|
inlinenoexcept |
Move from another awaitable.
rhs | The awaitable to move from, left in an unspecified state after this. |
dpp::awaitable< T >::~awaitable |
Destructor.
May signal to the promise that it was destroyed.
|
protected |
Abandons the promise.
Set the promise's state to broken and unlinks this awaitable.
bool dpp::awaitable< T >::await_ready |
Check whether or not co_await-ing this would suspend the caller, i.e. if we have the result or not.
|
inline |
Title :)
We use this in the destructor
|
inlinenoexcept |
Move from another awaitable.
rhs | The awaitable to move from, left in an unspecified state after this. |
|
delete |
Copy assignment 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 |
|
noexcept |
Check whether this awaitable refers to a valid promise.
|
friend |
|
friend |
Overload of the co_await operator.
|
protected |
Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable.