From ede287acd611f196a972065328a27ca8fae65ad4 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 4 Oct 2023 03:45:42 -0700 Subject: [PATCH] unnecessary Arc Mutex just send it bud --- src/worker.rs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/worker.rs b/src/worker.rs index 6ba37d8..34bdb7d 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -8,7 +8,6 @@ use parking_lot::Mutex; struct Worker { sender: mpsc::Sender, - receiver: Arc>>, value:Arc>, } @@ -17,14 +16,12 @@ impl Worker { let (sender, receiver) = mpsc::channel::(); let ret=Self { sender, - receiver:Arc::new(Mutex::new(receiver)), value:Arc::new(Mutex::new(value)), }; - let receiver=ret.receiver.clone(); let value=ret.value.clone(); thread::spawn(move || { loop { - match receiver.lock().recv() { + match receiver.recv() { Ok(task) => { println!("Worker got a task"); // Process the task