1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//! This module provides a simple wrapper
//! around the `tokio::task` module.

pub use tokio::task::JoinHandle;

/// Spawn a task globally (could be sent between threads).
pub fn spawn<F>(future: F) -> JoinHandle<()>
where
    F: futures::Future<Output = ()> + Send + 'static,
{
    tokio::spawn(future)
}

/// Spawn a task locally (in the same thread).
pub fn spawn_local<F>(future: F) -> JoinHandle<()>
where
    F: futures::Future<Output = ()> + 'static,
{
    tokio::task::spawn_local(future)
}