Expand description
auralis-task: Scoped async task runtime with explicit TaskScope
hierarchy, iterative cancellation, and priority scheduling.
§Architecture
- Global executor — a
thread_local!singleton with high- and low-priority queues. TaskScope— owns spawned futures; dropping a scope cancels all descendant scopes and their tasks iteratively (no recursion), preventing stack overflows in deeply nested UI trees.set_deferred— safe signal mutation fromDropcontexts.- Pluggable storage —
ScopeStoreandExecutor::new_instanceenable multi-request isolation for SSR or multi-threaded runtimes.
§Quick example
use auralis_task::{TaskScope, spawn_global};
let scope = TaskScope::new();
scope.spawn(async { /* ... */ });§Design decisions
The crate shares auralis_signal’s single-threaded-by-default
philosophy (Rc over Arc, RefCell over Mutex). For
multi-threaded use-cases, create an isolated Executor instance
per thread or per request. See the repository design docs for the
full rationale.
Macros§
- consume_
context - Shorthand for
scope.consume::<T>(). - provide_
context - Shorthand for
scope.provide(value).
Structs§
- Callback
Handle - Owns a resource that must be cleaned up when the owning
TaskScopeis dropped. - Executor
- A single-threaded async task executor with priority queues.
- Panic
Info - Information about a task panic, passed to the user-registered
set_panic_hook. - Scope
Store - A pluggable backend for per-task (or per-thread) scope storage.
- Task
Scope - A node in the scope tree that owns spawned tasks and carries a typed context for dependency injection.
- Yield
Now - Future returned by
yield_now.
Enums§
- Priority
- Task priority.
Traits§
- Schedule
Flush - Platform hook for scheduling a microtask callback.
- Time
Source - High-resolution time source for the executor’s time-budget accounting.
Functions§
- current_
scope - Get the currently active
TaskScope, if any. - find_
scope - Find a live
TaskScopeby its id. - init_
flush_ scheduler - Set the platform flush scheduler and install the signal deferred- callback hook (idempotent — subsequent calls are no-ops for the hook).
- init_
time_ source - Set the platform time source used for time-budget accounting.
- remove_
panic_ hook - Remove the global panic hook, restoring the default silent behaviour.
- reset_
executor_ for_ test - Completely reset the global executor to a pristine state.
- schedule_
callback - Schedule a closure to run at the start of the next executor flush.
- set_
deferred - Schedule a
Signal::setcall for the next executor flush. - set_
global_ time_ budget - Set the per-flush time budget on the global executor.
- set_
panic_ hook - Register a global panic hook called when any globally-spawned task panics.
- set_
scope_ store - Install a custom scope store.
- spawn_
global - Spawn a future on the global executor at low priority.
- spawn_
global_ with_ priority - Spawn a future on the global executor at the given priority.
- with_
current_ scope - Set the current
TaskScopefor the duration off. - with_
executor - Run
fwithexset as the current executor. - yield_
now - Return a
Futurethat yields control back to the executor once.