[−][src]Function async_spawner::register_spawner
pub fn register_spawner(
spawner: fn(_: Pin<Box<dyn Future<Output = ()> + Send>>)
)
Register a spawner.
#[async_std::main] async fn main() { fn async_std_spawn(future: Pin<Box<dyn Future<Output = ()> + Send>>) { async_std::task::spawn(future); } async_spawn::register_spawner(async_std_spawn); async_spawn::spawn(async { println!("spawned on async-std"); }); }
#[tokio::main] async fn main() { fn tokio_spawn(future: Pin<Box<dyn Future<Output = ()> + Send>>) { tokio::spawn(future); } async_spawn::register_spawner(tokio_spawn); async_spawn::spawn(async { println!("spawned on tokio"); }); }