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 () | |
Destructor. 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... | |
bool | done () const noexcept |
Function to check if the task has finished its execution entirely. More... | |
dpp::task< R > & | 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... | |
bool | await_ready () const |
Check whether or not a call to co_await will suspend the caller. More... | |
auto & | operator co_await () &noexcept |
Suspend the current coroutine until the task completes. More... | |
const auto & | operator co_await () const &noexcept |
Suspend the current coroutine until the task completes. More... | |
auto && | operator co_await () &&noexcept |
Suspend the current coroutine until the task completes. More... | |
Private Member Functions | |
dpp::task< R > && | 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... | |
Friends | |
class | detail::task::task_base< R > |
Internal use only base class containing common logic between task<R> and task<void>. It also serves to prevent await_suspend and await_resume from being used directly. More... | |
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. |
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.
bool dpp::task< R >::await_ready | ( | ) | const |
Check whether or not a call to co_await will suspend the caller.
This function is called by the standard library as a first step when using co_await. If it returns true then the caller is not suspended.
logic_exception | if the task is empty. |
Cancel the task, it will stop the next time it uses co_await. On co_await-ing this task, throws dpp::task_cancelled_exception.
|
noexcept |
Function to check if the task has finished its execution entirely.
|
inlinenoexcept |
Suspend the current coroutine until the task completes.
On | resumption, any exception thrown by the coroutine is propagated to the caller. |
|
inlinenoexcept |
Suspend the current coroutine until the task completes.
On | resumption, any exception thrown by the coroutine is propagated to the caller. |
|
inlinenoexcept |
Suspend the current coroutine until the task completes.
On | resumption, any exception thrown by the coroutine is propagated to the caller. |
Copy assignment is disabled.
Move assignment, grabs another task's coroutine handle.
other | Task to move the handle from |
|
friend |
Internal use only base class containing common logic between task<R> and task<void>. It also serves to prevent await_suspend and await_resume from being used directly.