use tokio::task::JoinHandle;
pub(crate) struct AbortOnDrop<T> {
handle: JoinHandle<T>,
}
impl<T> AbortOnDrop<T> {
pub fn new(handle: JoinHandle<T>) -> Self {
Self { handle }
}
}
impl<T> Drop for AbortOnDrop<T> {
fn drop(&mut self) {
self.handle.abort();
}
}