![]() |
mrs_lib
Various reusable classes, functions and utilities for use in MRS projects
|
Owning coroutine handle supporting cancellation. More...
#include <continuation.hpp>
Public Member Functions | |
| CancellableContinuation ()=default | |
| Construct empty continuation. | |
| CancellableContinuation (std::coroutine_handle< void >)=delete | |
| Cancellable continuation cannot be constructed from type erased handle. | |
| template<typename T > | |
| CancellableContinuation (std::coroutine_handle< T > handle) | |
| Construct continuation that will own the passed handle. | |
| ~CancellableContinuation () | |
| Destroy stored continuation if there is any. | |
| CancellableContinuation (const CancellableContinuation &)=delete | |
| CancellableContinuation & | operator= (const CancellableContinuation &)=delete |
| CancellableContinuation (CancellableContinuation &&other) noexcept | |
| CancellableContinuation & | operator= (CancellableContinuation &&other) noexcept |
| std::coroutine_handle | release () |
| Release ownership of the stored handle, giving it to the caller. | |
| void | cancel_and_destroy () |
| Cancel the stored continuation, if there is any. | |
| std::stop_token | get_token () const |
| Get stop token associated with the continuation. | |
Friends | |
| bool | operator== (const CancellableContinuation &continuation, std::nullptr_t) |
| Check if the current continuation is empty. | |
Owning coroutine handle supporting cancellation.
This class can be used to hold coroutine handle as owner. If it is destroyed while holding a handle, it cancels the coroutine.
Coroutine cancellation is performed in a way that should not exhaust stack space.
|
inlineexplicit |
Construct continuation that will own the passed handle.
| handle | Handle to the continuation to store. |
|
inline |
Cancel the stored continuation, if there is any.
The continuation will be empty after this call.
|
inline |
Release ownership of the stored handle, giving it to the caller.
The continuation will be empty after this call.