matrix_sdk_ffi/
task_handle.rsuse tokio::task::JoinHandle;
use tracing::debug;
#[derive(uniffi::Object)]
pub struct TaskHandle {
handle: JoinHandle<()>,
}
impl TaskHandle {
pub fn new(handle: JoinHandle<()>) -> Self {
Self { handle }
}
}
#[matrix_sdk_ffi_macros::export]
impl TaskHandle {
pub fn cancel(&self) {
debug!("Cancelling the task handle");
self.handle.abort();
}
pub fn is_finished(&self) -> bool {
self.handle.is_finished()
}
}
impl Drop for TaskHandle {
fn drop(&mut self) {
self.cancel();
}
}