D++ (DPP)
C++ Discord API Bot Library
|
A coroutine task. It starts immediately on construction and can be co_await-ed, making it perfect for parallel coroutines returning a value. More...
#include <coro/task.h>
Public Member Functions | |
task ()=default | |
Default constructor, creates a task not bound to a coroutine. More... | |
task (const task &)=delete | |
Copy constructor is disabled. More... | |
task (task &&other) noexcept | |
Move constructor, grabs another task's coroutine handle. More... | |
task & | operator= (const task &)=delete |
Copy assignment is disabled. More... | |
task & | operator= (task &&other) noexcept |
Move assignment, grabs another task's coroutine handle. More... | |
~task () | |
Destructor. More... | |
bool | done () const noexcept |
Function to check if the task has finished its execution entirely. More... | |
task & | cancel () &noexcept |
Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception. More... | |
task && | cancel () &&noexcept |
Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception. 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 | result_type = R |
The type of the result produced by this task. More... | |
Protected Member Functions | |
task (handle_t handle_) | |
Construct from a coroutine handle. Internal use only. More... | |
void | cleanup () |
Clean up our handle, cancelling any running task. 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 |
Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable. More... | |
Friends | |
struct | detail::task::promise_t< R > |
A coroutine task. It starts immediately on construction and can be co_await-ed, making it perfect for parallel coroutines returning a value.
R | Return type of the task. Cannot be a reference but can be void. |
|
protectedinherited |
The type of the result produced by this task.
|
protectedinherited |
Construct from a coroutine handle. Internal use only.
Default constructor, creates a task not bound to a coroutine.
Copy constructor is disabled.
Move constructor, grabs another task's coroutine handle.
other | Task to move the handle from |
Destructor.
Destroys the handle. If the task is still running, it will be cancelled.
|
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.
Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception.
Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception.
|
inlineprotected |
Clean up our handle, cancelling any running task.
|
inlinenoexcept |
Function to check if the task has finished its execution entirely.
|
inlineinherited |
Title :)
We use this in the destructor
Copy assignment is disabled.
Move assignment, grabs another task's coroutine handle.
other | Task to move the handle from |
|
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.
|
friend |
|
protectedinherited |
Non-owning pointer to the promise, which must be kept alive for the entire lifetime of the awaitable.