Skip to content

Commit 9c6f56b

Browse files
authored
Merge pull request #1903 from mo8it/threads3
Remove unneeded Arc
2 parents f3fdb07 + 71700c5 commit 9c6f56b

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

exercises/20_threads/threads3.rs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,18 @@ impl Queue {
2727
}
2828

2929
fn send_tx(q: Queue, tx: mpsc::Sender<u32>) -> () {
30-
let qc = Arc::new(q);
31-
let qc1 = Arc::clone(&qc);
32-
let qc2 = Arc::clone(&qc);
33-
3430
thread::spawn(move || {
35-
for val in &qc1.first_half {
31+
for val in q.first_half {
3632
println!("sending {:?}", val);
37-
tx.send(*val).unwrap();
33+
tx.send(val).unwrap();
3834
thread::sleep(Duration::from_secs(1));
3935
}
4036
});
4137

4238
thread::spawn(move || {
43-
for val in &qc2.second_half {
39+
for val in q.second_half {
4440
println!("sending {:?}", val);
45-
tx.send(*val).unwrap();
41+
tx.send(val).unwrap();
4642
thread::sleep(Duration::from_secs(1));
4743
}
4844
});

0 commit comments

Comments
 (0)