1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//! Local implementation of threads with tokio.

pub struct JoinHandle {
    inner: tokio::task::JoinHandle<()>,
}

impl JoinHandle {
    pub fn new<F>(future: F) -> Self
    where
        F: std::future::Future<Output = ()> + Send + 'static,
    {
        Self {
            inner: tokio::spawn(future),
        }
    }
}

impl crate::thread::Thread for JoinHandle {
    fn abort(&self) {
        self.inner.abort();
    }

    fn is_finished(&self) -> bool {
        self.inner.is_finished()
    }
}