baliuzeger / try_signalling

0 stars 0 forks source link

Need some way to avoid duplicate similar code of agent's init running connections. #3

Closed baliuzeger closed 5 years ago

baliuzeger commented 5 years ago

`{

code below code below code below

// here

fn run(&mut self, rx_confirm: CCReceiver, tx_report: CCSender) { let mut running_connections = Vec::new(); for conn in &self.out_connections_1 { let running_conn = conn.connection.upgrade().unwrap(); let (tx_conn_report, rx_conn_report) = crossbeam_channel::bounded(1); let (tx_conn_confirm, rx_conn_confirm) = crossbeam_channel::bounded(1); running_connections.push(RunningSet { instance: thread::spawn(move || {running_conn.lock().unwrap() .run_under_agent(rx_conn_confirm, tx_conn_report)}), report: rx_conn_report, confirm: tx_conn_confirm, }); } // failed to use a function of init_connections
for conn in &self.out_connections_2 { let running_conn = conn.connection.upgrade().unwrap(); let (tx_conn_report, rx_conn_report) = crossbeam_channel::bounded(1); let (tx_conn_confirm, rx_conn_confirm) = crossbeam_channel::bounded(1); running_connections.push(RunningSet { instance: thread::spawn(move || {running_conn.lock().unwrap() .run_under_agent(rx_conn_confirm, tx_conn_report)}), report: rx_conn_report, confirm: tx_conn_confirm, }); }`

baliuzeger commented 5 years ago

done on branch multi-runtime-mode