Skip to content

Commit 3ed1dca

Browse files
committed
Explicitly cancel the coordinator when it is dropped
1 parent d1bbebc commit 3ed1dca

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

compiler/base/orchestrator/src/coordinator.rs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ pub struct Coordinator<B> {
893893
stable: OnceCell<Container>,
894894
beta: OnceCell<Container>,
895895
nightly: OnceCell<Container>,
896-
token: CancellationToken,
896+
token: CancelOnDrop,
897897
}
898898

899899
/// Runs things.
@@ -910,7 +910,7 @@ where
910910
B: Backend,
911911
{
912912
pub fn new(limits: Arc<dyn ResourceLimits>, backend: B) -> Self {
913-
let token = CancellationToken::new();
913+
let token = CancelOnDrop(CancellationToken::new());
914914

915915
Self {
916916
limits,
@@ -1153,13 +1153,28 @@ where
11531153
container
11541154
.get_or_try_init(|| {
11551155
let limits = self.limits.clone();
1156-
let token = self.token.clone();
1156+
let token = self.token.0.clone();
11571157
Container::new(channel, limits, token, &self.backend)
11581158
})
11591159
.await
11601160
}
11611161
}
11621162

1163+
#[derive(Debug, Default)]
1164+
struct CancelOnDrop(CancellationToken);
1165+
1166+
impl CancelOnDrop {
1167+
fn cancel(&self) {
1168+
self.0.cancel();
1169+
}
1170+
}
1171+
1172+
impl Drop for CancelOnDrop {
1173+
fn drop(&mut self) {
1174+
self.0.cancel();
1175+
}
1176+
}
1177+
11631178
#[derive(Debug)]
11641179
struct Container {
11651180
permit: Box<dyn ContainerPermit>,

0 commit comments

Comments
 (0)