Use Input for ValueInvalidationSignal
This commit is contained in:
parent
b79edeef0a
commit
8c761fe0d4
@ -117,7 +117,7 @@ impl<O: 'static, S: Synchronicity> GraphBuilder<O, S> {
|
||||
) -> (Input<V>, ValueInvalidationSignal<V>) {
|
||||
let input = self.add_node(InvalidatableConstNode::new(value));
|
||||
let signal = ValueInvalidationSignal {
|
||||
value: Rc::clone(&input.value),
|
||||
input: input.clone(),
|
||||
signal: self.make_invalidation_signal(&input),
|
||||
};
|
||||
(input, signal)
|
||||
|
@ -333,17 +333,14 @@ impl Clone for InvalidationSignal {
|
||||
///
|
||||
/// See [`GraphBuilder::add_invalidatable_value`].
|
||||
pub struct ValueInvalidationSignal<V> {
|
||||
value: Rc<RefCell<Option<V>>>,
|
||||
input: Input<V>,
|
||||
signal: InvalidationSignal,
|
||||
}
|
||||
|
||||
impl<V: NodeValue> ValueInvalidationSignal<V> {
|
||||
/// Get a reference to current value for the node corresponding to this signal.
|
||||
pub fn value(&self) -> impl Deref<Target = V> + '_ {
|
||||
Ref::map(self.value.borrow(), |opt| {
|
||||
opt.as_ref()
|
||||
.expect("invalidatable value node must be initialized with value")
|
||||
})
|
||||
self.input.value()
|
||||
}
|
||||
|
||||
/// Set a new value for the node corresponding to this signal.
|
||||
@ -352,7 +349,7 @@ impl<V: NodeValue> ValueInvalidationSignal<V> {
|
||||
/// for the corresponding node. The graph will not be re-evaluated until [`Graph::evaluate`] or
|
||||
/// [`Graph::evaluate_async`] is next called.
|
||||
pub fn set_value(&self, value: V) {
|
||||
let mut current_value = self.value.borrow_mut();
|
||||
let mut current_value = self.input.value.borrow_mut();
|
||||
if !current_value
|
||||
.as_ref()
|
||||
.expect("invalidatable value node must be initialized with value")
|
||||
@ -367,7 +364,7 @@ impl<V: NodeValue> ValueInvalidationSignal<V> {
|
||||
impl<V> Clone for ValueInvalidationSignal<V> {
|
||||
fn clone(&self) -> Self {
|
||||
Self {
|
||||
value: Rc::clone(&self.value),
|
||||
input: self.input.clone(),
|
||||
signal: self.signal.clone(),
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user