cpu-worker: clear tasks on shutdown
This commit is contained in:
parent
80f1310e3a
commit
0f2d63ef44
2 changed files with 14 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue