matrix_sdk_ffi/
task_handle.rs1use tokio::task::JoinHandle;
2use tracing::debug;
3
4#[derive(uniffi::Object)]
9pub struct TaskHandle {
10 handle: JoinHandle<()>,
11}
12
13impl TaskHandle {
14 pub fn new(handle: JoinHandle<()>) -> Self {
16 Self { handle }
17 }
18}
19
20#[matrix_sdk_ffi_macros::export]
21impl TaskHandle {
22 pub fn cancel(&self) {
24 debug!("Cancelling the task handle");
25
26 self.handle.abort();
27 }
28
29 pub fn is_finished(&self) -> bool {
31 self.handle.is_finished()
32 }
33}
34
35impl Drop for TaskHandle {
36 fn drop(&mut self) {
37 self.cancel();
38 }
39}