use std::sync::Arc; use std::sync::Mutex; use crate::stream::StreamConsumer; use crate::stream::StreamProducer; pub struct Edge { // Represents the index of the block owning the Out end in the graph // And the the output index within that block pub from: Option, // Represents the index of the block owning the In end in the graph // And the the input index within that block pub to: Option, } #[derive(Clone, Copy, PartialEq, Eq, Debug)] pub struct BlockIOIndex { pub block_index: usize, pub port_index: usize, } pub struct In { stream: Option>, // Will rarely be accessed edge: Arc>, } pub struct Out { stream: Option>, // Will rarely be accessed edge: Arc>, } impl In { pub fn set_block_index(&self, index: BlockIOIndex) { self.edge.lock().unwrap().to = Some(index); } pub fn get_producer_block(&self) -> Option { self.edge.lock().unwrap().from } } impl Out { pub fn set_block_index(&self, index: BlockIOIndex) { self.edge.lock().unwrap().from = Some(index); } pub fn get_consumer_block(&self) -> Option { self.edge.lock().unwrap().to } }