|
Aria 2.0.0
C++23 MVVM framework (C++20 minimum) — reactive, coroutine-first, ABI-layered
|
Goal: bound a network call by a deadline, and/or race several sources and take whichever answers first — cancelling the losers.
See aria/async/timeout.hpp and aria/async/when_all.hpp (when_any), and the race contract notes in those headers.
with_timeout(timer, duration, factory, mode) runs factory and races it against a timer. timer is any IDelayedScheduler (e.g. VirtualTimeExecutor in tests, a real UI timer in production). The token-accepting factory form lets the inner work cancel cooperatively when the deadline wins:
when_any_cancellable takes factories that each receive a CancellationToken; once a winner emerges, every loser's token is flipped so it can stop cooperatively:
The simpler when_any(std::vector<Task<T>>) form races tasks that have no token attached — losers run to completion in the background. Use the cancellable form whenever the losing work is expensive or has side effects.
async/async_command_builder.hpp ships action_with_timeout and action_with_retry that wrap these combinators for AsyncCommand actions, so a command can be "each attempt gets its own 3s timeout, up to 3 attempts" without hand-rolling the race (see the header for the exact wrapper signatures).