MCPcopy Create free account
hub / github.com/CleanCut/ultimate_rust2 / main

Function main

example/cafeteria/src/main.rs:31–57  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

29}
30
31fn 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}

Callers

nothing calls this directly

Calls 1

cafeteria_workerFunction · 0.85

Tested by

no test coverage detected