use std::panic::Location;
pub use super::backend::task::*;
use super::runtime::Handle;
use crate::maybe_send::MaybeSend;
#[track_caller]
pub fn spawn<F>(future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
let loc = Location::caller();
super::backend::task::spawn(crate::no_block::watch_blanket_at("spawn", loc, future))
}
#[track_caller]
pub fn spawn_on<F>(handle: &Handle, future: F) -> JoinHandle<F::Output>
where
F: Future + Send + 'static,
F::Output: Send + 'static,
{
let loc = Location::caller();
handle.spawn(crate::no_block::watch_blanket_at("spawn", loc, future))
}
pub fn spawn_blocking<F, R>(f: F) -> JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
super::backend::task::spawn_blocking(f)
}
pub fn spawn_sync<F, R>(f: F) -> JoinHandle<R>
where
F: FnOnce() -> R + MaybeSend + 'static,
R: MaybeSend + 'static,
{
spawn_blocking(f)
}
pub fn spawn_blocking_on<F, R>(handle: &Handle, f: F) -> JoinHandle<R>
where
F: FnOnce() -> R + Send + 'static,
R: Send + 'static,
{
handle.spawn_blocking(f)
}