pub struct Aggregator<I: IntoIoSignature, O: IntoIoSignature> { /* private fields */ }Expand description
The Aggregator is put “around” some implementation of Node. It handles waiting for data, edge assignment
as well as using default data provided by the nodes default() function if no edge is supplied for some port.
Implementations§
Source§impl<I, O> Aggregator<I, O>where
I: IntoIoSignature,
O: IntoIoSignature,
impl<I, O> Aggregator<I, O>where
I: IntoIoSignature,
O: IntoIoSignature,
Sourcepub fn from_node<N>(node: N) -> Self
pub fn from_node<N>(node: N) -> Self
Creates this aggregator from some Node implementing object. Takes ownership of that node. If that is not desired, use the
from_arc() function.
Examples found in repository?
examples/math.rs (line 54)
51fn main(){
52 let ex = Executor::new();
53
54 let add_node1 = Arc::new(Mutex::new(Aggregator::from_node(Add)));
55 let add_node2 = Arc::new(Mutex::new(Aggregator::from_node(Add)));
56 let printer = Arc::new(Mutex::new(Aggregator::from_node(Printer)));
57
58 Edge::connect(add_node1.clone(), 0, add_node2.clone(), 1).expect("Failed to connect edge");
59 Edge::connect(add_node2.clone(), 0, printer.clone(), 0).expect("Failed to connect edge");
60
61 //Should execute since the other edge is set by the default value
62 add_node1.lock().unwrap().set_in_from_edge(ex.clone(), 1, Box::new(2.0 as f32)).expect("Failed to set input");
63
64 std::thread::sleep(std::time::Duration::from_secs(1));
65}pub fn from_arc<N>(node: Arc<Mutex<N>>) -> Self
Trait Implementations§
Source§impl<I, O> AbstAggregator for Aggregator<I, O>where
I: IntoIoSignature,
O: IntoIoSignature,
impl<I, O> AbstAggregator for Aggregator<I, O>where
I: IntoIoSignature,
O: IntoIoSignature,
fn set_in_edge(&mut self, edge: Edge) -> Result<(), DErr>
fn set_out_edge(&mut self, edge: Edge) -> Result<(), DErr>
Source§fn notify_in_remove(&mut self, port_idx: usize) -> Result<Edge, DErr>
fn notify_in_remove(&mut self, port_idx: usize) -> Result<Edge, DErr>
Removes the in edge at
port_idx. Returns the removed edge, or why this wasn’t possible.Source§fn notify_out_remove(&mut self, port_idx: usize) -> Result<Edge, DErr>
fn notify_out_remove(&mut self, port_idx: usize) -> Result<Edge, DErr>
Removes the out edge at
port_idx. Returns the removed edge, or why this wasn’t possible.fn set_in_from_edge( &mut self, executor: Arc<Executor>, idx: usize, value: Box<dyn Any>, ) -> Result<(), DErr>
fn set_default_value( &mut self, idx: usize, value: Box<dyn Any>, ) -> Result<(), DErr>
fn in_type_id(&self, in_port_idx: usize) -> Option<TypeId>
fn out_type_id(&self, out_port_idx: usize) -> Option<TypeId>
Source§impl<O> Executable for Aggregator<(), O>where
O: IntoIoSignature,
impl<O> Executable for Aggregator<(), O>where
O: IntoIoSignature,
Auto Trait Implementations§
impl<I, O> Freeze for Aggregator<I, O>
impl<I, O> RefUnwindSafe for Aggregator<I, O>
impl<I, O> Send for Aggregator<I, O>
impl<I, O> Sync for Aggregator<I, O>
impl<I, O> Unpin for Aggregator<I, O>
impl<I, O> UnwindSafe for Aggregator<I, O>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more