polars_utils/async_utils/
tokio_handle_ext.rs1use std::future::Future;
2use std::pin::Pin;
3use std::task::{Context, Poll};
4
5pub struct AbortOnDropHandle<T>(pub tokio::task::JoinHandle<T>);
7
8impl<T> Future for AbortOnDropHandle<T> {
9 type Output = Result<T, tokio::task::JoinError>;
10
11 fn poll(mut self: Pin<&mut Self>, cx: &mut Context<'_>) -> Poll<Self::Output> {
12 Pin::new(&mut self.0).poll(cx)
13 }
14}
15
16impl<T> Drop for AbortOnDropHandle<T> {
17 fn drop(&mut self) {
18 self.0.abort();
19 }
20}