async-spawner 1.0.0

executor independent task spawner
Documentation

async-spawner

Executor independent task spawner.

use core::future::Future;
use core::pin::Pin;

#[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");
    });
}
use core::future::Future;
use core::pin::Pin;

#[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");
    });
}

License

This project is licensed under either of

at your option.