Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
Loading...
Searching...
No Matches
aria::async::CancellationSource Class Reference

#include <cancellation.hpp>

Public Member Functions

 CancellationSource ()
CancellationToken token () const noexcept
void cancel ()
 Trigger cancellation.
bool is_cancelled () const noexcept
 ~CancellationSource ()
 Auto-cancel on destruction — perfect for ViewModelScope.
 CancellationSource (const CancellationSource &)=delete
CancellationSourceoperator= (const CancellationSource &)=delete
 CancellationSource (CancellationSource &&)=default
CancellationSourceoperator= (CancellationSource &&other) noexcept

Constructor & Destructor Documentation

◆ CancellationSource() [1/3]

aria::async::CancellationSource::CancellationSource ( )
inline

◆ ~CancellationSource()

aria::async::CancellationSource::~CancellationSource ( )
inline

Auto-cancel on destruction — perfect for ViewModelScope.

◆ CancellationSource() [2/3]

aria::async::CancellationSource::CancellationSource ( const CancellationSource & )
delete

◆ CancellationSource() [3/3]

aria::async::CancellationSource::CancellationSource ( CancellationSource && )
default

Member Function Documentation

◆ token()

CancellationToken aria::async::CancellationSource::token ( ) const
inlinenodiscardnoexcept

◆ cancel()

void aria::async::CancellationSource::cancel ( )
inline

Trigger cancellation.

All currently registered callbacks fire synchronously on the calling thread; any later observers see is_cancelled() == true.

Coroutine resumes triggered by callbacks are deferred: the callback enqueues the coroutine handle, and this function drains the queue once every callback has returned. That keeps the stack shape free of std::function::operator() indirection at the moment a resumed coroutine throws — see the comment on detail::DeferredResumeContext for the full rationale.

Safe to call on a moved-from CancellationSource (state_ may be nullptr). The destructor relies on this guard.

◆ is_cancelled()

bool aria::async::CancellationSource::is_cancelled ( ) const
inlinenodiscardnoexcept

◆ operator=() [1/2]

CancellationSource & aria::async::CancellationSource::operator= ( const CancellationSource & )
delete

◆ operator=() [2/2]

CancellationSource & aria::async::CancellationSource::operator= ( CancellationSource && other)
inlinenoexcept

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