Base type for a coroutine, starts on co_await.
More...
#include <coro/coroutine.h>
|
| using | result_type = R |
| | The type of the result produced by this coroutine.
|
|
| | coroutine ()=default |
| | Default constructor, creates an empty coroutine.
|
| | coroutine (const coroutine &)=delete |
| | Copy constructor is disabled.
|
| | coroutine (coroutine &&other) noexcept |
| | Move constructor, grabs another coroutine's handle.
|
| | ~coroutine () |
| | Destructor, destroys the handle.
|
| auto | operator co_await () |
| coroutine & | operator= (const coroutine &)=delete |
| | Copy assignment is disabled.
|
| coroutine & | operator= (coroutine &&other) noexcept |
| | Move assignment, grabs another coroutine's handle.
|
| auto | sync_wait () |
| | Blocks this thread and waits for the awaitable to finish.
|
| auto | sync_wait_for (const std::chrono::duration< Rep, Period > &duration) |
| | Blocks this thread and waits for the awaitable to finish.
|
| auto | sync_wait_until (const std::chrono::time_point< Clock, Duration > &time) |
| | Blocks this thread and waits for the awaitable to finish.
|
|
| auto | sync_wait_impl (auto &&do_wait) |
| | Implementation for sync_wait. This is code used by sync_wait, sync_wait_for, sync_wait_until.
|
template<typename R>
class dpp::coroutine< R >
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. |
◆ result_type
The type of the result produced by this coroutine.
◆ coroutine() [1/3]
Default constructor, creates an empty coroutine.
◆ coroutine() [2/3]
Copy constructor is disabled.
◆ coroutine() [3/3]
Move constructor, grabs another coroutine's handle.
- Parameters
-
| other | Coroutine to move the handle from |
◆ ~coroutine()
Destructor, destroys the handle.
◆ operator co_await()
◆ 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 |
◆ sync_wait()
Blocks this thread and waits for the awaitable to finish.
- Attention
- This will BLOCK THE THREAD. It is likely you want to use co_await instead.
- Returns
- If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.
-
If T is non-void, returns a std::optional<T> for which an absence of value means timed out.
◆ sync_wait_for()
| auto dpp::basic_awaitable< coroutine< R > >::sync_wait_for |
( |
const std::chrono::duration< Rep, Period > & | duration | ) |
|
|
inlineinherited |
Blocks this thread and waits for the awaitable to finish.
- Attention
- This will BLOCK THE THREAD. It is likely you want to use co_await instead.
- Parameters
-
| duration | Maximum duration to wait for |
- Returns
- If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.
-
If T is non-void, returns a std::optional<T> for which an absence of value means timed out.
◆ sync_wait_impl()
Implementation for sync_wait. This is code used by sync_wait, sync_wait_for, sync_wait_until.
- Template Parameters
-
| Timed | Whether the wait function times out or not |
- Parameters
-
| do_wait | Function to do the actual wait on the cv |
- Returns
- If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.
-
If T is non-void, returns a std::optional<T> for which an absence of value means timed out.
◆ sync_wait_until()
| auto dpp::basic_awaitable< coroutine< R > >::sync_wait_until |
( |
const std::chrono::time_point< Clock, Duration > & | time | ) |
|
|
inlineinherited |
Blocks this thread and waits for the awaitable to finish.
- Attention
- This will BLOCK THE THREAD. It is likely you want to use co_await instead.
- Parameters
-
| time | Maximum time point to wait for |
- Returns
- If T is void, returns a boolean for which true means the awaitable completed, false means it timed out.
-
If T is non-void, returns a std::optional<T> for which an absence of value means timed out.
◆ detail::coroutine::promise_t< R >
Promise has friend access for the constructor.