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

#include <view_model_scope.hpp>

Public Member Functions

 ViewModelScope ()
 ~ViewModelScope ()
 ViewModelScope (const ViewModelScope &)=delete
ViewModelScopeoperator= (const ViewModelScope &)=delete
 ViewModelScope (ViewModelScope &&)=delete
ViewModelScopeoperator= (ViewModelScope &&)=delete
void attach (ViewModel &vm)
 Tie this scope's lifetime to the ViewModel's destructor.
async::CancellationToken token () const noexcept
bool is_cancelled () const noexcept
std::size_t inflight_count () const noexcept
void cancel () noexcept
 Request cancellation only (non-blocking).
bool cancel_and_join (std::chrono::milliseconds timeout=kJoinTimeoutMs) noexcept
 Cancel + synchronously wait for all in-flight coroutines to exit, with the given timeout.
template<typename Fn>
void launch (Fn factory)
void launch_simple (async::Task< void > task)

Static Public Attributes

static constexpr std::chrono::milliseconds kJoinTimeoutMs {5000}
 Default timeout for cancel_and_join() invoked from the VM's destroy-hook.

Constructor & Destructor Documentation

◆ ViewModelScope() [1/3]

aria::binding::ViewModelScope::ViewModelScope ( )
inline

◆ ~ViewModelScope()

aria::binding::ViewModelScope::~ViewModelScope ( )
inline

◆ ViewModelScope() [2/3]

aria::binding::ViewModelScope::ViewModelScope ( const ViewModelScope & )
delete

◆ ViewModelScope() [3/3]

aria::binding::ViewModelScope::ViewModelScope ( ViewModelScope && )
delete

Member Function Documentation

◆ operator=() [1/2]

ViewModelScope & aria::binding::ViewModelScope::operator= ( const ViewModelScope & )
delete

◆ operator=() [2/2]

ViewModelScope & aria::binding::ViewModelScope::operator= ( ViewModelScope && )
delete

◆ attach()

void aria::binding::ViewModelScope::attach ( ViewModel & vm)
inline

Tie this scope's lifetime to the ViewModel's destructor.

Must be called from the VM's ctor body.

The hook also covers scopes owned outside the ViewModel. A scope member already cancels in its own destructor; attaching it remains harmless because cancellation and joining are idempotent.

◆ token()

async::CancellationToken aria::binding::ViewModelScope::token ( ) const
inlinenodiscardnoexcept

◆ is_cancelled()

bool aria::binding::ViewModelScope::is_cancelled ( ) const
inlinenodiscardnoexcept

◆ inflight_count()

std::size_t aria::binding::ViewModelScope::inflight_count ( ) const
inlinenodiscardnoexcept

◆ cancel()

void aria::binding::ViewModelScope::cancel ( )
inlinenoexcept

Request cancellation only (non-blocking).

◆ cancel_and_join()

bool aria::binding::ViewModelScope::cancel_and_join ( std::chrono::milliseconds timeout = kJoinTimeoutMs)
inlinenoexcept

Cancel + synchronously wait for all in-flight coroutines to exit, with the given timeout.

Returns true on full drain.

◆ launch()

template<typename Fn>
void aria::binding::ViewModelScope::launch ( Fn factory)
inline

◆ launch_simple()

void aria::binding::ViewModelScope::launch_simple ( async::Task< void > task)
inline

Member Data Documentation

◆ kJoinTimeoutMs

std::chrono::milliseconds aria::binding::ViewModelScope::kJoinTimeoutMs {5000}
staticconstexpr

Default timeout for cancel_and_join() invoked from the VM's destroy-hook.

Matches the underlying CoroutineScope default and is generous enough for cooperatively-cancelled work; a stuck coroutine is reported as a leak rather than blocking process shutdown.


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