From 928654c7df420c9abb87ca53c794fbf57adad4c5 Mon Sep 17 00:00:00 2001 From: Quaternions Date: Wed, 4 Oct 2023 02:19:41 -0700 Subject: [PATCH] make that shit compile --- src/worker.rs | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/src/worker.rs b/src/worker.rs index 2898d04..afaa3a3 100644 --- a/src/worker.rs +++ b/src/worker.rs @@ -17,9 +17,7 @@ impl Worker { fn start(self) { thread::spawn(move || { loop { - let (ref lock, ref cvar) = &*self.receiver; - let task = lock.lock().unwrap().recv(); - match task { + match self.receiver.0.lock().recv() { Ok(task) => { println!("Worker {} got a task: {}", self.id, task); // Process the task @@ -69,14 +67,10 @@ fn main() { if !is_worker_active { // If the worker is done, signal it to process a new task is_active.store(true, Ordering::SeqCst); - let (ref lock, ref cvar) = &*receiver; - cvar.notify_one(); + thread::sleep(std::time::Duration::from_secs(2)); // Send a new task sender.send("New Task".to_string()).unwrap(); - - // Wait for the worker to finish processing - cvar.wait_while(lock.lock(), |&active| active); } else { println!("Worker is still active. Skipping new task."); }