8 个版本
| 0.1.6 | 2020 年 4 月 21 日 | 
|---|---|
| 0.1.5 | 2020 年 3 月 3 日 | 
| 0.1.4 | 2020 年 1 月 8 日 | 
| 0.1.2 | 2019 年 12 月 24 日 | 
| 0.0.0 | 2019 年 9 月 13 日 | 
174 在 #non-blocking 中排名
606 每月下载量
在 32 个 crate 中使用 (直接使用 4 个)
92KB
955 行
Tokio Compat
tokio 0.2 和旧版本之间的兼容层。
概述
此 crate 提供兼容运行时,允许同时运行使用 tokio 0.1 运行时服务的 futures 0.1 futures 以及使用 tokio 0.2 运行时服务的 std::future futures。
示例
同时启动 tokio 0.1 和 tokio 0.2 futures
use futures_01::future::lazy;
tokio_compat::run(lazy(|| {
    // spawn a `futures` 0.1 future using the `spawn` function from the
    // `tokio` 0.1 crate:
    tokio_01::spawn(lazy(|| {
        println!("hello from tokio 0.1!");
        Ok(())
    }));
    // spawn an `async` block future on the same runtime using `tokio`
    // 0.2's `spawn`:
    tokio_02::spawn(async {
        println!("hello from tokio 0.2!");
    });
    Ok(())
}))
兼容运行时的 futures 可以使用 0.1 和 0.2 版本 tokio 的 timer API
use std::time::{Duration, Instant};
use futures_01::future::lazy;
use tokio_compat::prelude::*;
tokio_compat::run_std(async {
    // Wait for a `tokio` 0.1 `Delay`...
    let when = Instant::now() + Duration::from_millis(10);
    tokio_01::timer::Delay::new(when)
        // convert the delay future into a `std::future` that we can `await`.
        .compat()
        .await
        .expect("tokio 0.1 timer should work!");
    println!("10 ms have elapsed");
    // Wait for a `tokio` 0.2 `Delay`...
    let when = Instant::now() + Duration::from_millis(20);
    tokio_02::timer::delay(when).await;
    println!("20 ms have elapsed");
});
许可证
本项目采用 MIT 许可证。
贡献
除非您明确表示,否则您提交给 Tokio 的任何贡献都应按 MIT 许可,不附加任何额外条款或条件。
依赖关系
~4.5MB
~71K SLoC