|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
#include <async_command.hpp>
Public Types | |
| using | Action = typename Core::Action |
Public Member Functions | |
| template<typename Ui, typename Worker, typename Fn> requires (detail::CancellableAction<Fn, Args...> || detail::PlainAction<Fn, Args...>) && std::is_base_of_v<IExecutor, Ui> && std::is_base_of_v<IExecutor, Worker> && (!std::is_same_v<Ui, IExecutor> || !std::is_same_v<Worker, IExecutor>) | |
| AsyncCommand (Ui &ui, Worker &worker, Fn action, AsyncCommandPolicy policy=AsyncCommandPolicy::Parallel) | |
| Construct with a "plain" or "cancellable" action. | |
| template<typename Fn> requires detail::CancellableAction<Fn, Args...> || detail::PlainAction<Fn, Args...> | |
| AsyncCommand (IExecutor &ui, IExecutor &worker, Fn action, AsyncCommandPolicy policy=AsyncCommandPolicy::Parallel) | |
| Type-erased overload — the choice for ViewModels that receive IExecutor& from a DI container. | |
| ~AsyncCommand () | |
| AsyncCommand (const AsyncCommand &)=delete | |
| AsyncCommand & | operator= (const AsyncCommand &)=delete |
| void | execute (Args... args) |
| Fire-and-forget. | |
| Task< AsyncCommandResult< R > > | co_execute (Args... args) |
| Awaitable version: caller co_awaits a structured result. | |
| AsyncCommandPolicy | policy () const noexcept |
Public Attributes | |
| Property< bool > & | is_executing |
| Property< std::optional<::aria::Error > > & | last_error |
| Property< std::string > & | last_error_message |
| Property< std::optional< R > > & | last_result |
| using aria::async::AsyncCommand< R, Args >::Action = typename Core::Action |
|
inline |
Construct with a "plain" or "cancellable" action.
The shape is detected at compile time; if you pass a (Args...) callable, we synthesise a wrapper that discards the token. If your callable is ambiguous (happens with generic lambdas), cast it to the desired std::function first.
Executor safety is enforced as eagerly as possible:
|
inline |
Type-erased overload — the choice for ViewModels that receive IExecutor& from a DI container.
|
inline |
|
delete |
|
delete |
|
inline |
Fire-and-forget.
Concurrency shape controlled by policy_. Errors are reported via the installed error_sink_ and the observable last_error Property; this function itself is noexcept-by-design (the wrapper coroutine cannot propagate).
|
inline |
Awaitable version: caller co_awaits a structured result.
Never throws. All four invocation outcomes — Completed, Dropped (policy=DropIfRunning while busy), Cancelled (OperationCancelled at any cancellation point), Failed (action threw any other exception) — are folded into the returned AsyncCommandResult. Callers branch on .completed() / .dropped() / .cancelled() / .failed() instead of writing try { co_await ... } catch (...) boilerplate around every invocation site.
|
inlinenodiscardnoexcept |
| Property<bool>& aria::async::AsyncCommand< R, Args >::is_executing |
| Property<std::optional<::aria::Error> >& aria::async::AsyncCommand< R, Args >::last_error |
| Property<std::string>& aria::async::AsyncCommand< R, Args >::last_error_message |
| Property<std::optional<R> >& aria::async::AsyncCommand< R, Args >::last_result |