Skip to content

Commit

Permalink
Delay drop of context up to return_to_pool()-ing
Browse files Browse the repository at this point in the history
  • Loading branch information
ryoqun committed Dec 14, 2023
1 parent 049a126 commit 60b1bd2
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions unified-scheduler-pool/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,6 @@ impl<TH: TaskHandler> InstalledScheduler for PooledScheduler<TH> {
if keep_result_with_timings {
None
} else {
drop(
self.context
.take()
.expect("active context should be dropped"),
);
// current simplest form of this trait impl doesn't block the current thread materially
// just with the following single mutex lock. Suppose more elaborated synchronization
// across worker threads here in the future...
Expand All @@ -286,7 +281,12 @@ impl<TH: TaskHandler> InstalledScheduler for PooledScheduler<TH> {
}
}

fn return_to_pool(self: Box<Self>) {
fn return_to_pool(mut self: Box<Self>) {
drop(
self.context
.take()
.expect("active context should be dropped"),
);
self.pool.clone().return_scheduler(self)
}
}
Expand Down

0 comments on commit 60b1bd2

Please sign in to comment.