pax-tokio

Explicit Tokio ownership and scoped tasks for native Pax applications.

Construct your runtime, then pass it and cx.lifetime() to [Executor::owned] from the root initializer. The adapter uses that exact runtime and retains cleanup until workers finish. UI callbacks do not implicitly enter Tokio.

Structs

BoundTasks

UI-local bound executor. Each spawn creates an independently cancellable operation below the owner. Keep a component-bound helper from on_mount when later event contexts belong to controls inside that component.

Implementations

spawn
pub fn spawn(&self, future: impl Future + Send + 'static) -> Result<TaskControl, AsyncError>

Monitor ordinary work. Raw Property clones captured here remain writable after cancellation; use spawn_into for revocable result publication.

spawn_into
pub fn spawn_into<T: SharedPropertyValue>(&self, target: &Property<T>, future: impl Future + Send + 'static) -> Result<TaskControl, AsyncError>

Publish the returned value only if this task's operation is still live. The future receives no raw clone of the target.

spawn_with_completion
pub fn spawn_with_completion<T: Send + 'static>(&self, future: impl Future + Send + 'static, callback: impl FnOnce(TaskOutcome<T>) + 'static) -> Result<TaskControl, AsyncError>

Return a result or task panic to a UI-local closure, never running that closure inline on the executor. Cancellation suppresses queued delivery.


Executor

An explicitly supplied Tokio runtime bound to an application's lifetime. Cloning this client shares the same runtime; dropping a client does not end application authority. Closing the application cancels work and retains the runtime on its owner thread until shutdown is acknowledged.

Implementations

borrowed
pub fn borrowed(handle: Handle, lifetime: &AppContext) -> AppResult<Self>

Borrow a continuously driven runtime. Its external owner must outlive cleanup; this adapter never shuts down that runtime.

for_application
pub fn for_application(&self, app: &AppContext) -> Result<BoundTasks, AsyncError>

Bind work to this application lifetime.

for_node
pub fn for_node(&self, node: &impl AsyncScopeSource) -> Result<BoundTasks, AsyncError>

Bind work to the exact node supplied by the caller.

for_scope
pub fn for_scope(&self, scope: AsyncScope) -> Result<BoundTasks, AsyncError>

Bind work to an explicit operation or other scope.

handle
pub fn handle(&self) -> Result<Handle, AsyncError>

Access the exact supplied runtime for advanced, untracked work.

owned
pub fn owned(runtime: Runtime, lifetime: &AppContext) -> AppResult<Self>

Adopt this exact multithread runtime without changing its configuration. The lifetime must be open. Construct inside the cartridge initializer; never pass a Rust Runtime or Handle through the native cartridge ABI.