1
0
Fork 0
forked from wry/wry

cpu-worker: clear tasks on shutdown

This commit is contained in:
Julian Orth 2025-07-19 00:34:44 +02:00
parent 80f1310e3a
commit 0f2d63ef44
2 changed files with 14 additions and 0 deletions

View file

@ -200,6 +200,15 @@ impl Drop for PendingJob {
}
impl CpuWorkerData {
fn clear(&self) {
self.jobs_to_enqueue.clear();
self.new_jobs.lock().clear();
self.completed_jobs_remote.lock().queue.clear();
self.completed_jobs_local.borrow_mut().clear();
self.pending_jobs.clear();
self.pending_job_data_cache.take();
}
async fn wait_for_completions(self: Rc<Self>) {
let mut buf = TypedBuf::<u64>::new();
loop {
@ -302,6 +311,10 @@ impl CpuWorker {
})
}
pub fn clear(&self) {
self.data.clear();
}
pub fn submit(&self, job: Box<dyn CpuJob>) -> PendingJob {
let mut job = NonNull::from(Box::leak(job));
let id = self.data.next.next();

View file

@ -1072,6 +1072,7 @@ impl State {
self.const_40hz_latch.clear();
self.cursor_user_groups.clear();
self.cursor_user_group_hardware_cursor.take();
self.cpu_worker.clear();
}
pub fn remove_toplevel_id(&self, id: ToplevelIdentifier) {