[][src]Struct proc_graph::Network

pub struct Network<T> { /* fields omitted */ }

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]

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]

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

impl<T: Default> Default for Network<T>[src]

Auto Trait Implementations

impl<T> !RefUnwindSafe for Network<T>

impl<T> Send for Network<T> where
    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]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.