Corium 1.1.0
High-Performance Zero-Heap C++20 MPSC Application Runtime
Loading...
Searching...
No Matches
corium::async::CancellationToken Class Reference

Lightweight, zero-heap cooperative cancellation token for C++20 coroutines and services. More...

#include <CancellationToken.hpp>

+ Collaboration diagram for corium::async::CancellationToken:

Classes

struct  WhenCancelledAwaiter
 Awaitable that suspends until this token is cancelled. More...
 

Public Member Functions

void cancel () noexcept
 Signal cancellation to all observing tasks.
 
constexpr CancellationToken () noexcept=default
 
bool isCancelled () const noexcept
 Check if cancellation has been requested.
 
void reset () noexcept
 Reset token state to uncancelled.
 
WhenCancelledAwaiter whenCancelled () noexcept
 

Detailed Description

Lightweight, zero-heap cooperative cancellation token for C++20 coroutines and services.

Constructor & Destructor Documentation

◆ CancellationToken()

constexpr corium::async::CancellationToken::CancellationToken ( )
constexprdefaultnoexcept

Member Function Documentation

◆ cancel()

void corium::async::CancellationToken::cancel ( )
inlinenoexcept

Signal cancellation to all observing tasks.

Note
Wakes any suspended coroutine awaiting whenCancelled() immediately.
Examples
/home/runner/work/corium/corium/include/corium/async/CancellationToken.hpp.

◆ isCancelled()

bool corium::async::CancellationToken::isCancelled ( ) const
inlinenoexcept

Check if cancellation has been requested.

Returns
True if cancel() has been invoked, false otherwise.
Examples
/home/runner/work/corium/corium/include/corium/async/CancellationToken.hpp.
+ Here is the caller graph for this function:

◆ reset()

void corium::async::CancellationToken::reset ( )
inlinenoexcept

Reset token state to uncancelled.

Note
Allows reusing the token for subsequent asynchronous task executions.
Examples
/home/runner/work/corium/corium/include/corium/async/CancellationToken.hpp.

◆ whenCancelled()

WhenCancelledAwaiter corium::async::CancellationToken::whenCancelled ( )
inlinenoexcept

The documentation for this class was generated from the following file: