From b63aeb37ab22ec65476118d1455c7964308dec0b Mon Sep 17 00:00:00 2001 From: Karol Herbst Date: Mon, 8 Jul 2024 16:34:22 +0200 Subject: [PATCH] Revert "rusticl/queue: gracefully stop the worker thread" Apparently this code caused issues and the fix was only papering over the issue, which I now I can't trigger anyway. This reverts commit 9d458b7fc15a87720397b5b3d94a0971ed4aa59d. Fixes: 9d458b7fc15 ("rusticl/queue: gracefully stop the worker thread") Part-of: (cherry picked from commit 47377b550f394e8d7fb1a79e8abd801214865027) --- .pick_status.json | 2 +- src/gallium/frontends/rusticl/core/queue.rs | 21 +++++---------------- 2 files changed, 6 insertions(+), 17 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 5c369346888..0a1cf77ad6d 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -17864,7 +17864,7 @@ "description": "Revert \"rusticl/queue: gracefully stop the worker thread\"", "nominated": false, "nomination_type": 2, - "resolution": 4, + "resolution": 1, "main_sha": null, "because_sha": "9d458b7fc15a87720397b5b3d94a0971ed4aa59d", "notes": null diff --git a/src/gallium/frontends/rusticl/core/queue.rs b/src/gallium/frontends/rusticl/core/queue.rs index 590ec9b8255..c70e24b0d9f 100644 --- a/src/gallium/frontends/rusticl/core/queue.rs +++ b/src/gallium/frontends/rusticl/core/queue.rs @@ -11,7 +11,6 @@ use rusticl_opencl_gen::*; use std::cmp; use std::mem; -use std::mem::ManuallyDrop; use std::ops::Deref; use std::sync::mpsc; use std::sync::Arc; @@ -76,7 +75,7 @@ struct QueueState { last: Weak, // `Sync` on `Sender` was stabilized in 1.72, until then, put it into our Mutex. // see https://github.com/rust-lang/rust/commit/5f56956b3c7edb9801585850d1f41b0aeb1888ff - chan_in: ManuallyDrop>>>, + chan_in: mpsc::Sender>>, } pub struct Queue { @@ -86,7 +85,7 @@ pub struct Queue { pub props: cl_command_queue_properties, pub props_v2: Option>, state: Mutex, - thrd: ManuallyDrop>, + _thrd: JoinHandle<()>, } impl_cl_type_trait!(cl_command_queue, Queue, CL_INVALID_COMMAND_QUEUE); @@ -118,9 +117,9 @@ impl Queue { state: Mutex::new(QueueState { pending: Vec::new(), last: Weak::new(), - chan_in: ManuallyDrop::new(tx_q), + chan_in: tx_q, }), - thrd: ManuallyDrop::new(thread::Builder::new() + _thrd: thread::Builder::new() .name("rusticl queue thread".into()) .spawn(move || { // Track the error of all executed events. This is only needed for in-order @@ -198,7 +197,7 @@ impl Queue { flush_events(&mut flushed, &ctx); } }) - .unwrap()), + .unwrap(), })) } @@ -261,15 +260,5 @@ impl Drop for Queue { // commands in command_queue. // TODO: maybe we have to do it on every release? let _ = self.flush(true); - - let state = self.state.get_mut().unwrap(); - - unsafe { - // disconnect the channel - ManuallyDrop::drop(&mut state.chan_in); - - // and now explicitly wait on the thread to quit, because it won't happen implicitly. - ManuallyDrop::take(&mut self.thrd).join().unwrap(); - } } }