#[cfg(not(feature = "native-tokio"))]
compile_error!(
"Must chose a native runtime by enabling a feature flag. Right now only tokio is supported. If you have a different runtime that you want please create an issue on github."
);
#[cfg(feature = "native-tokio")]
pub fn spawn<F: crate::SpawnableNoReturn>(future: F) {
tokio::spawn(future);
}
pub fn spawn_thread_with_return<F, T>(f: F) -> futures::channel::oneshot::Receiver<T>
where
F: FnOnce() -> T,
F: Send + 'static,
T: Send + 'static + std::fmt::Debug,
{
let (tx, rx) = futures::channel::oneshot::channel();
std::thread::spawn(move || {
let task_result = f();
let result = tx.send(task_result);
if let Err(err_msg) = result {
tracing::error!("failed to send result from `spawn_thread_with_return`: {err_msg:?}");
}
});
rx
}