pub struct Control<T: ?Sized> { /* private fields */ }Expand description
Marks a variable as a state variable which can be used in conjunction with the until!-macro.
Whenever a control variable changes its value, the runtime system checks whether any other parts of the model are currently waiting for the variable to attain a certain value.
Implementations§
Source§impl<T> Control<T>
impl<T> Control<T>
Sourcepub fn set(&self, val: T)
pub fn set(&self, val: T)
Assigns a new value to the control variable.
This can lead to potential activations of waiting processes.
Sourcepub fn swap(&self, other: &Self)
pub fn swap(&self, other: &Self)
Swaps the values of two control variables. The difference to
core::mem::swap is that this function doesn’t require an exclusive
reference.
Sourcepub fn replace(&self, val: T) -> T
pub fn replace(&self, val: T) -> T
Replaces the current value of the control variable with a new one and returns it.
This can lead to potential activations of waiting processes.
Sourcepub fn update<F>(&self, f: F)
pub fn update<F>(&self, f: F)
Updates the contained value using a function and returns the new value.
Sourcepub fn take(&self) -> Twhere
T: Default,
pub fn take(&self) -> Twhere
T: Default,
Takes the value of the control variable, leaving Default::default() in
its place.
Sourcepub fn get_mut(&mut self) -> &mut T
pub fn get_mut(&mut self) -> &mut T
Returns a mutable reference to the underlying data.
This call borrows the control variable mutably (at compile-time) which guarantees that we possess the only reference.
Sourcepub fn unchecked_set(&self, val: T)
pub fn unchecked_set(&self, val: T)
Assigns a new value to the control variable without notifying pending control conditions.
Use this method if you want to change the inner value without scheduling continuations that depend on it. Once finished, you may call notify directly.