async_runtime
Executor-neutral task lifetimes and bounded delivery to the UI thread.
A scope is local authority. Only its producers, guarded publishers and task reporters can cross threads. A successful send means accepted, not delivered.
Structs
AsyncLimits
Application resource limits. Counts do not bound the byte size of user values.
Properties
scopes
Type: usize
tasks
Type: usize
publishers
Type: usize
endpoints
Type: usize
message_slots
Type: usize
channel_capacity
Type: usize
callbacks_per_turn
Type: usize
callback_time
Type: Duration
AsyncScope
Local lifetime controller. Cancellation revokes descendants before requesting task abortion. Keep a component's scope from its mount context when handlers later receive contexts for child controls.
use pax_runtime_api::{application::{ApplicationInstance, AppOptions}, TargetInfo};
let app = ApplicationInstance::prepare(TargetInfo::default(), AppOptions::default()).unwrap();
let scope = app.context().async_scope().unwrap();
std::thread::spawn(move || scope.cancel());
Implementations
child
pub fn child(&self) -> Result<Self, AsyncError>
Create an independent operation underneath this lifetime.
register_task
pub fn register_task(&self, start: impl FnOnce(TaskReporter) -> Box<dyn FnOnce()> + 'static) -> Result<TaskControl, AsyncError>
Adapter entry point. start runs only after activation and returns a
nonblocking cancellation request. Retaining the control is optional.
replace
pub fn replace<T: SharedPropertyValue>(&self, previous: &mut Option<AsyncScope>, property: &Property<T>, initial: T) -> Result<AsyncScope, AsyncError>
Revoke the previous request before publishing replacement state and creating its new operation. Registration failure leaves the old work closed.
Closed
A rejected publication retains the caller's value.
Properties
0
Type: T
Completion
Single-use producer. Dropping it unused releases the callback on the UI turn.
GuardedPublisher
A shared property writer whose commit is atomic with lifetime revocation.
Cloning this handle does not acquire another registration. Raw Property
clones remain deliberately unguarded.
SendFuture
Capacity wait owned by one send attempt; dropping it unregisters its waker.
TaskControl
UI-owned task control; dropping it does not detach work from its scope.
Implementations
status_property
pub fn status_property(&self) -> Published<TaskStatus>
A snapshot property for reactive status displays; applications should not mutate this adapter-owned state.
TaskReporter
Transferable completion signal owned by an executor adapter. Drop means the task stopped without normal completion, usually after an abort request.
UiSender
Transferable producer for a bounded UI channel. Its callback stays local.
Implementations
send
pub fn send(&self, value: T) -> SendFuture<'_, T>
Wait for capacity without blocking the UI or an executor thread.
try_send
pub fn try_send(&self, value: T) -> Result<(), TrySendError<T>>
Enqueue immediately, reporting Full or Closed without losing the value.
UiSubscription
Keeps a UI channel subscribed. Drop closes it and releases its local callback.
Enums
AsyncError
New work was rejected before it could start or reserve resources.
Variants
Closed
Limit(&'static str)
ZeroCapacity
TaskOutcome
The callback result keeps application Result<T, E> separate from a task panic.
Variants
Completed(T)
Panicked(String)
TaskStatus
Observable task state. A cancellation request is not proof that work stopped.
Variants
Staged
Running
CancelRequested
Completed
Cancelled
Panicked(String)
TrySendError
A nonblocking channel send either retains the value or accepts it exactly once.
Variants
Full(T)
Closed(T)
Traits
AsyncScopeSource
A local owner that can bind work to its lifetime without exposing a node to
an executor. Implemented by AppContext and runtime NodeContext.
Functions
panic_message
pub fn panic_message(panic: Box<dyn Any + Send>) -> String
Converts an unwinding panic into an observable task/callback failure.