Expand description
auralis-signal: Reactive signal primitive with version tracking and proactive waker deregistration.
§Overview
This crate provides Signal<T> and Memo<T> — the foundational
reactive primitives of the Auralis kernel. Every signal carries a
monotonic version number. When a change-detection future is dropped
before resolution, it eagerly removes its waker from the signal’s
internal list, preventing stale-waker accumulation (the “proactive
deregistration” guarantee).
Signals and memos support optional labels for diagnostic output,
and the add_schedule_observer hook lets external tools observe
every signal mutation. Behind the diagnostics feature (enabled by
auralis_task’s debug feature), a thread-local registry tracks
live nodes for dump_registry().
The crate is zero-dependency, #![forbid(unsafe_code)], and
intentionally single-threaded (!Send / !Sync). See the
repository design docs for the
rationale behind those choices.
§Quick example
use auralis_signal::Signal;
let sig = Signal::new(0);
sig.set(1);
assert_eq!(sig.read(), 1);Re-exports§
pub use prop::IntoProp;pub use prop::Prop;pub use prop::StaticProp;pub use subscription::subscribe_to;pub use subscription::SubscriptionHandle;
Modules§
- prop
Prop<T>— unified static / dynamic value trait.- subscription
- RAII subscription handle that unsubscribes on drop.
Macros§
Structs§
- Filter
Changed Future - A
Futurethat yields a new signal value only when it satisfies a predicate. - MapChanged
Future - A
Futurethat transforms each new signal value through a mapping function. - Memo
- A lazy, auto-tracking computed signal.
- Observer
Token - Opaque token returned by
add_schedule_observer. Pass it toremove_schedule_observerto deregister. - Signal
- A reactive value container with monotonic version tracking.
- Signal
Changed Future - A
Futurethat completes with the signal’s current value on the next mutation. - Signal
Map - A lightweight unidirectional read-only projection of a
Signal.
Functions§
- add_
schedule_ observer - Add an observer that is called (with no arguments) whenever a
Signal::setschedules a subscriber notification. - add_
schedule_ observer_ with_ identity - Like
add_schedule_observer, but the observer receives the mutated signal’sstate_addrand new version number. - batch
- Run
fin a batch context. - in_
batch - Return
trueif currently inside abatchcontext. - install_
timing_ hook - Install a microsecond-precision timer hook.
- now_us
- Return the current time in microseconds, or 0 if no hook is
installed and the platform doesn’t support
Instant. - remove_
schedule_ observer - Remove a previously-registered observer.
- subscribe
- Register a subscriber callback and return its id.
- unsubscribe
- Remove a subscriber by id.