Skip to content

Commit 2b66ce1

Browse files
committed
multitask: properly detach when dropping JoinHandle
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
1 parent 64adcfe commit 2b66ce1

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/task/join_handle.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,15 @@ impl<T> JoinHandle<T> {
6666
}
6767
}
6868

69+
#[cfg(not(target_os = "unknown"))]
70+
impl<T> Drop for JoinHandle<T> {
71+
fn drop(&mut self) {
72+
if let Some(handle) = self.handle.take() {
73+
handle.detach();
74+
}
75+
}
76+
}
77+
6978
impl<T> Future for JoinHandle<T> {
7079
type Output = T;
7180

0 commit comments

Comments
 (0)