1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
//! Compatibility between `tokio` 0.2 and legacy versions.
//!
//! ## Overview
//!
//! This crate provides compatibility runtimes that allow running both `futures` 0.1
//! futures that use `tokio` 0.1 runtime services _and_ `std::future` futures that
//! use `tokio` 0.2 runtime services.
//!
//! ### Examples
//!
//! Spawning both `tokio` 0.1 and `tokio` 0.2 futures:
//!
//! ```rust
//! 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 on the compat runtime can use `timer` APIs from both 0.1 and 0.2
//! versions of `tokio`:
//!
//! ```rust
//! use std::time::{Duration, Instant};
//! 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`...
//! tokio_02::time::delay_for(Duration::from_millis(20)).await;
//! println!("20 ms have elapsed");
//! });
//! ```
//!
//! ## Feature Flags
//!
//! - `rt-current-thread`: enables the `current_thread` compatibilty runtime
//! - `rt-full`: enables the `current_thread` and threadpool compatibility
//! runtimes (enabled by default)
pub use ;