Skip to main content

ReactiveEngineV0

Struct ReactiveEngineV0 

Source
pub struct ReactiveEngineV0 { /* private fields */ }

Implementations§

Source§

impl ReactiveEngineV0

Source

pub fn node_count(&self) -> usize

Source

pub fn node_kind( &self, node: ReactiveNodeIdV0, ) -> Result<ReactiveNodeKindV0, ReactiveEngineErrorV0>

Source

pub fn state( &self, node: ReactiveNodeIdV0, ) -> Result<&ReactiveStateV0, ReactiveEngineErrorV0>

Source

pub fn is_necessary( &self, node: ReactiveNodeIdV0, ) -> Result<bool, ReactiveEngineErrorV0>

Source

pub fn is_stale( &self, node: ReactiveNodeIdV0, ) -> Result<bool, ReactiveEngineErrorV0>

Source

pub fn node_recompute_count( &self, node: ReactiveNodeIdV0, ) -> Result<usize, ReactiveEngineErrorV0>

Source

pub fn delta_update_count( &self, node: ReactiveNodeIdV0, ) -> Result<usize, ReactiveEngineErrorV0>

Source

pub fn current_wave(&self) -> u64

Source

pub fn is_stabilizing(&self) -> bool

Source

pub fn has_pending_work(&self) -> bool

Source

pub fn deposit( &mut self, node: ReactiveNodeIdV0, state: ReactiveStateV0, ) -> Result<(), ReactiveEngineErrorV0>

Queues the latest value for an input-like node. The deposit is applied only when the next wave begins, including when it arrives between bounded steps of the current wave.

Examples found in repository?
examples/performance_envelope.rs (lines 72-75)
61fn measure(changes_input: bool) -> Result<Vec<Duration>, Box<dyn Error>> {
62    let (mut engine, inputs) = graph()?;
63    let mut samples = Vec::with_capacity(EVENT_COUNT);
64    for event in 0..EVENT_COUNT {
65        let index = event % INPUT_COUNT;
66        let value = if changes_input {
67            (index + event + 1) as u64
68        } else {
69            index as u64
70        };
71        let started = Instant::now();
72        engine.deposit(
73            inputs[index],
74            ReactiveStateV0::available(ReactiveValueV0::Counter(value)),
75        )?;
76        settle(&mut engine)?;
77        engine.drain_effect_receipts();
78        samples.push(started.elapsed());
79    }
80    Ok(samples)
81}
Source

pub fn observe( &mut self, node: ReactiveNodeIdV0, ) -> Result<(), ReactiveEngineErrorV0>

Examples found in repository?
examples/performance_envelope.rs (line 55)
36fn graph() -> Result<(ReactiveEngineV0, Vec<ReactiveNodeIdV0>), Box<dyn Error>> {
37    let policy = ChangePolicyV0::exact("performanceSemanticValue");
38    let mut graph = ReactiveGraphBuilderV0::new();
39    let mut inputs = Vec::with_capacity(INPUT_COUNT);
40    let mut projections = Vec::with_capacity(INPUT_COUNT);
41    for index in 0..INPUT_COUNT {
42        let input = graph.add_input(
43            ReactiveStateV0::available(ReactiveValueV0::Counter(index as u64)),
44            policy,
45        );
46        inputs.push(input);
47        projections.push((
48            format!("projection-{index}"),
49            graph.add_map(input, project_counter, policy),
50        ));
51    }
52    let fold = graph.add_delta_fold(projections, policy)?;
53    let boundary = graph.add_effect_boundary(fold, "performance-observation", policy);
54    let mut engine = graph.build()?;
55    engine.observe(boundary)?;
56    settle(&mut engine)?;
57    engine.drain_effect_receipts();
58    Ok((engine, inputs))
59}
Source

pub fn unobserve( &mut self, node: ReactiveNodeIdV0, ) -> Result<(), ReactiveEngineErrorV0>

Source

pub fn stabilize_step( &mut self, maximum_recomputes: usize, ) -> Result<StabilizeStatusV0, ReactiveEngineErrorV0>

Examples found in repository?
examples/performance_envelope.rs (line 28)
25fn settle(engine: &mut ReactiveEngineV0) -> Result<(), Box<dyn Error>> {
26    loop {
27        if matches!(
28            engine.stabilize_step(4_096)?,
29            StabilizeStatusV0::Settled { .. }
30        ) {
31            return Ok(());
32        }
33    }
34}
Source

pub fn stabilize_until_settled( &mut self, maximum_recomputes: usize, ) -> Result<StabilizeStatusV0, ReactiveEngineErrorV0>

Source

pub fn drain_effect_receipts(&mut self) -> Vec<EffectReceiptV0>

Examples found in repository?
examples/performance_envelope.rs (line 57)
36fn graph() -> Result<(ReactiveEngineV0, Vec<ReactiveNodeIdV0>), Box<dyn Error>> {
37    let policy = ChangePolicyV0::exact("performanceSemanticValue");
38    let mut graph = ReactiveGraphBuilderV0::new();
39    let mut inputs = Vec::with_capacity(INPUT_COUNT);
40    let mut projections = Vec::with_capacity(INPUT_COUNT);
41    for index in 0..INPUT_COUNT {
42        let input = graph.add_input(
43            ReactiveStateV0::available(ReactiveValueV0::Counter(index as u64)),
44            policy,
45        );
46        inputs.push(input);
47        projections.push((
48            format!("projection-{index}"),
49            graph.add_map(input, project_counter, policy),
50        ));
51    }
52    let fold = graph.add_delta_fold(projections, policy)?;
53    let boundary = graph.add_effect_boundary(fold, "performance-observation", policy);
54    let mut engine = graph.build()?;
55    engine.observe(boundary)?;
56    settle(&mut engine)?;
57    engine.drain_effect_receipts();
58    Ok((engine, inputs))
59}
60
61fn measure(changes_input: bool) -> Result<Vec<Duration>, Box<dyn Error>> {
62    let (mut engine, inputs) = graph()?;
63    let mut samples = Vec::with_capacity(EVENT_COUNT);
64    for event in 0..EVENT_COUNT {
65        let index = event % INPUT_COUNT;
66        let value = if changes_input {
67            (index + event + 1) as u64
68        } else {
69            index as u64
70        };
71        let started = Instant::now();
72        engine.deposit(
73            inputs[index],
74            ReactiveStateV0::available(ReactiveValueV0::Counter(value)),
75        )?;
76        settle(&mut engine)?;
77        engine.drain_effect_receipts();
78        samples.push(started.elapsed());
79    }
80    Ok(samples)
81}
Source

pub fn verify_delta_fold( &self, node: ReactiveNodeIdV0, ) -> Result<(), DeltaFoldParityErrorV0>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.