[−][src]Struct proc_graph::Network
A network of processes. Each process has a mailbox and the set of addresses (senders) it needs to communicate with its neighbors.
Methods
impl<T> Network<T> where
T: Default + Send + 'static,
[src]
T: Default + Send + 'static,
pub fn new() -> Self
[src]
pub fn add_process<'a, F>(
&'a mut self,
name: &'static str,
adj: Vec<&'static str>,
body: F
) where
F: Fn(HashMap<String, Sender<(String, T)>>, Receiver<(String, T)>) + Send + 'static,
[src]
&'a mut self,
name: &'static str,
adj: Vec<&'static str>,
body: F
) where
F: Fn(HashMap<String, Sender<(String, T)>>, Receiver<(String, T)>) + Send + 'static,
Adding a process to the network takes a name, its neighbors, and a closure which acts as the entire body of this process. I.e., if you want the process to run forever, that loop has to be inside the given closure.
The process's neighbor's addresses (the senders) and the process's mailbox are passed into the closure. The only abstraction provided here is converting the given graph—described the process and its adjacencies—into mailboxes and addresses.
pub fn start_and_wait(self)
[src]
Start the processes in this network. Blocks until all of the processes have finished.
pub fn start(self)
[src]
Start the processes in this network.
Trait Implementations
Auto Trait Implementations
impl<T> !RefUnwindSafe for Network<T>
impl<T> Send for Network<T> where
T: Send,
T: Send,
impl<T> !Sync for Network<T>
impl<T> Unpin for Network<T>
impl<T> !UnwindSafe for Network<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,