()
| 29 | } |
| 30 | |
| 31 | fn main() { |
| 32 | let (orders_tx, orders_rx) = channel::unbounded(); |
| 33 | let orders_rx2 = orders_rx.clone(); |
| 34 | let (lunches_tx, lunches_rx) = channel::unbounded(); |
| 35 | let lunches_tx2 = lunches_tx.clone(); |
| 36 | |
| 37 | let alice_handle = thread::spawn(|| cafeteria_worker("alice", orders_rx2, lunches_tx2)); |
| 38 | let zack_handle = thread::spawn(|| cafeteria_worker("zack", orders_rx, lunches_tx)); |
| 39 | |
| 40 | for order in vec![ |
| 41 | "polish dog", |
| 42 | "caesar salad", |
| 43 | "onion soup", |
| 44 | "reuben sandwich", |
| 45 | ] { |
| 46 | println!("ORDER: {}", order); |
| 47 | let _ = orders_tx.send(order); |
| 48 | } |
| 49 | drop(orders_tx); |
| 50 | |
| 51 | for lunch in lunches_rx { |
| 52 | println!("Order Up! -> {:?}", lunch); |
| 53 | } |
| 54 | |
| 55 | let _ = alice_handle.join(); |
| 56 | let _ = zack_handle.join(); |
| 57 | } |
nothing calls this directly
no test coverage detected