summaryrefslogtreecommitdiff
path: root/exercises/20_threads
diff options
context:
space:
mode:
authorliv <mokou@fastmail.com>2024-03-18 18:43:30 +0100
committerGitHub <noreply@github.com>2024-03-18 18:43:30 +0100
commit9c6f56b836e91da9071830d4dd4a64417fdced9d (patch)
treecc4c3d5c6d060d0839ee07bb2d4a01bf4baca870 /exercises/20_threads
parentf3fdb075077d5ea3bb5efcbbc0e222d29480bca5 (diff)
parent71700c506c34af636fc9d4098b5bebc21dfe9a3c (diff)
Merge pull request #1903 from mo8it/threads3
Remove unneeded Arc
Diffstat (limited to 'exercises/20_threads')
-rw-r--r--exercises/20_threads/threads3.rs12
1 files changed, 4 insertions, 8 deletions
diff --git a/exercises/20_threads/threads3.rs b/exercises/20_threads/threads3.rs
index 91006bb..acb97b4 100644
--- a/exercises/20_threads/threads3.rs
+++ b/exercises/20_threads/threads3.rs
@@ -27,22 +27,18 @@ impl Queue {
}
fn send_tx(q: Queue, tx: mpsc::Sender<u32>) -> () {
- let qc = Arc::new(q);
- let qc1 = Arc::clone(&qc);
- let qc2 = Arc::clone(&qc);
-
thread::spawn(move || {
- for val in &qc1.first_half {
+ for val in q.first_half {
println!("sending {:?}", val);
- tx.send(*val).unwrap();
+ tx.send(val).unwrap();
thread::sleep(Duration::from_secs(1));
}
});
thread::spawn(move || {
- for val in &qc2.second_half {
+ for val in q.second_half {
println!("sending {:?}", val);
- tx.send(*val).unwrap();
+ tx.send(val).unwrap();
thread::sleep(Duration::from_secs(1));
}
});