Skip to main content

Crate auralis_task

Crate auralis_task 

Source
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 from Drop contexts.
  • Pluggable storageScopeStore and Executor::new_instance enable 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§

CallbackHandle
Owns a resource that must be cleaned up when the owning TaskScope is dropped.
Executor
A single-threaded async task executor with priority queues.
PanicInfo
Information about a task panic, passed to the user-registered set_panic_hook.
ScopeStore
A pluggable backend for per-task (or per-thread) scope storage.
TaskScope
A node in the scope tree that owns spawned tasks and carries a typed context for dependency injection.
YieldNow
Future returned by yield_now.

Enums§

Priority
Task priority.

Traits§

ScheduleFlush
Platform hook for scheduling a microtask callback.
TimeSource
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 TaskScope by 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::set call 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 TaskScope for the duration of f.
with_executor
Run f with ex set as the current executor.
yield_now
Return a Future that yields control back to the executor once.