summaryrefslogblamecommitdiffstats
path: root/futures/src/executor/tokio.rs
blob: 20802cebfd16c7d3dd86b3ead5db64ce2cd96b82 (plain) (tree)
1
2
3
4
5



                    
                      














                                                                        
use crate::Executor;

use futures::Future;

/// A `tokio` runtime.
pub type Tokio = tokio::runtime::Runtime;

impl Executor for Tokio {
    fn new() -> Result<Self, futures::io::Error> {
        tokio::runtime::Runtime::new()
    }

    fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
        let _ = tokio::runtime::Runtime::spawn(self, future);
    }

    fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
        tokio::runtime::Runtime::enter(self, f)
    }
}