Skip to main content

Crate auralis_signal

Crate auralis_signal 

Source
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§

memo
Create a Memo with automatic clone of captured identifiers.

Structs§

FilterChangedFuture
A Future that yields a new signal value only when it satisfies a predicate.
MapChangedFuture
A Future that transforms each new signal value through a mapping function.
Memo
A lazy, auto-tracking computed signal.
ObserverToken
Opaque token returned by add_schedule_observer. Pass it to remove_schedule_observer to deregister.
Signal
A reactive value container with monotonic version tracking.
SignalChangedFuture
A Future that completes with the signal’s current value on the next mutation.
SignalMap
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::set schedules a subscriber notification.
add_schedule_observer_with_identity
Like add_schedule_observer, but the observer receives the mutated signal’s state_addr and new version number.
batch
Run f in a batch context.
in_batch
Return true if currently inside a batch context.
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.

Type Aliases§

SubscriberId