Base type for a coroutine, starts on co_await.
More...
#include "coro/coroutine.h"
Base type for a coroutine, starts on co_await.
- Warning
- - This feature is EXPERIMENTAL. The API may change at any time and there may be bugs. Please report any to GitHub Issues or to our Discord Server.
-
- Using co_await on this object more than once is undefined behavior.
- Template Parameters
-
R | Return type of the coroutine. Can be void, or a complete object that supports move construction and move assignment. |
◆ coroutine() [1/3]
dpp::coroutine::coroutine |
( |
| ) |
|
|
default |
Default constructor, creates an empty coroutine.
◆ coroutine() [2/3]
dpp::coroutine::coroutine |
( |
const coroutine & |
| ) |
|
|
delete |
Copy constructor is disabled.
◆ coroutine() [3/3]
dpp::coroutine::coroutine |
( |
coroutine && |
other | ) |
|
|
noexcept |
Move constructor, grabs another coroutine's handle.
- Parameters
-
other | Coroutine to move the handle from |
◆ ~coroutine()
dpp::coroutine::~coroutine |
( |
| ) |
|
Destructor, destroys the handle.
◆ await_ready()
bool dpp::coroutine::await_ready |
( |
| ) |
const |
First function called by the standard library when the coroutine is co_await-ed.
- Exceptions
-
invalid_operation_exception | if the coroutine is empty or finished. |
- Returns
- bool Whether the coroutine is done
◆ operator co_await() [1/3]
auto&& dpp::coroutine::operator co_await |
( |
| ) |
&& |
|
inlinenoexcept |
Suspend the caller until the coroutine completes.
- Exceptions
-
On | resumption, any exception thrown by the coroutine is propagated to the caller. |
- Returns
- On resumption, this expression evaluates to the result object of type R, as an rvalue reference.
◆ operator co_await() [2/3]
auto& dpp::coroutine::operator co_await |
( |
| ) |
& |
|
inlinenoexcept |
Suspend the caller until the coroutine completes.
- Exceptions
-
On | resumption, any exception thrown by the coroutine is propagated to the caller. |
- Returns
- On resumption, this expression evaluates to the result object of type R, as a reference.
◆ operator co_await() [3/3]
const auto& dpp::coroutine::operator co_await |
( |
| ) |
const & |
|
inlinenoexcept |
Suspend the caller until the coroutine completes.
- Exceptions
-
On | resumption, any exception thrown by the coroutine is propagated to the caller. |
- Returns
- On resumption, this expression evaluates to the result object of type R, as a const reference.
◆ operator=() [1/2]
Copy assignment is disabled.
◆ operator=() [2/2]
Move assignment, grabs another coroutine's handle.
- Parameters
-
other | Coroutine to move the handle from |
◆ detail::coroutine::coroutine_base< R >
Internal use only base class containing common logic between coroutine<R> and coroutine<void>.
It also serves to prevent await_suspend and await_resume from being used directly.
- Warning
- For internal use only, do not use.
- See also
- operator co_await()
The documentation for this class was generated from the following files: