use std::future::Future; use tokio::task::{AbortHandle, JoinHandle, JoinSet}; #[cfg(tokio_unstable)] pub(crate) fn spawn(name: &str, future: F) -> std::io::Result> where F: Future + Send + 'static, F::Output: Send + 'static, { tokio::task::Builder::new().name(name).spawn(future) } #[cfg(tokio_unstable)] pub(crate) fn spawn_in( set: &mut JoinSet, name: &str, future: F, ) -> std::io::Result where F: Future + Send + 'static, F::Output: Send + 'static, { set.build_task().name(name).spawn(future) } #[cfg(not(tokio_unstable))] pub(crate) fn spawn(name: &str, future: F) -> std::io::Result> where F: Future + Send + 'static, F::Output: Send + 'static, { let _ = name; Ok(tokio::task::spawn(future)) } #[cfg(not(tokio_unstable))] pub(crate) fn spawn_in( set: &mut JoinSet, name: &str, future: F, ) -> std::io::Result where F: Future + Send + 'static, F::Output: Send + 'static, { let _ = name; Ok(set.spawn(future)) }