Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rust 1.43 KB | None | 0 0
  1. use std::thread;
  2. use std::sync::mpsc::channel;
  3. use std::sync::mpsc::Sender;
  4. use std::sync::mpsc::Receiver;
  5. use std::sync::Arc;
  6. use std::sync::Mutex;
  7. use eveamcp::OutgoingPort;
  8. use eveamcp::IncomingPort;
  9. use structs::*;
  10. use nodes;
  11.  
  12. pub fn init() -> Vec<thread::JoinHandle<()>> {
  13.     let mut threads = vec![];
  14.  
  15.     let (root_28_0_sender, root_28_0_receiver) : (Sender<ParsedEthernet>, Receiver<ParsedEthernet>) = channel();
  16.  
  17.     let root_27_0_senders_arc = Arc::new(Mutex::new(vec!()));
  18.     {
  19.         let root_27_0_senders_arc = root_27_0_senders_arc.clone();
  20.         {
  21.             let ref mut root_27_0_senders = *(root_27_0_senders_arc.lock().unwrap());
  22.             root_27_0_senders.push(root_28_0_sender.clone());
  23.         }
  24.     }
  25.  
  26.     {
  27.         let root_27_0_senders_arc = root_27_0_senders_arc.clone();
  28.         threads.push(thread::spawn(move || {
  29.             let root_27_0 = OutgoingPort {
  30.                 senders: root_27_0_senders_arc
  31.             };
  32.  
  33.             nodes::NodeGRootG27 {
  34.                 port_root_27_0: root_27_0,
  35.             }.run();
  36.         }));
  37.     }
  38.  
  39.  
  40.     threads.push(thread::spawn(move || {
  41.         let root_28_0 = IncomingPort {
  42.             receiver: root_28_0_receiver
  43.         };
  44.         nodes::NodeGRootG28 {
  45.             port_root_28_0: root_28_0,
  46.         }.run();
  47.     }));
  48.     threads.push(thread::spawn(move || {
  49.         root_27_0_senders_arc.lock();
  50.     }));
  51.     return threads;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement