Skip to content

Commit 3253852

Browse files
committed
chore: update tokio to v1.0
1 parent f8aef03 commit 3253852

3 files changed

Lines changed: 24 additions & 3 deletions

File tree

futures/Cargo.toml

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ categories = ["gui"]
1212

1313
[features]
1414
thread-pool = ["futures/thread-pool"]
15+
tokio = ["tokio_new", "async-stream"]
1516

1617
[dependencies]
1718
log = "0.4"
@@ -25,10 +26,15 @@ version = "0.2"
2526
optional = true
2627
features = ["rt-core", "rt-threaded", "time", "stream"]
2728

28-
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
29-
version = "0.3"
29+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio_new]
30+
package = "tokio"
31+
version = "1.0"
32+
optional = true
33+
features = ["rt-multi-thread", "time"]
34+
35+
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-stream]
36+
version = "0.3.0"
3037
optional = true
31-
features = ["rt-multi-thread", "time", "stream"]
3238

3339
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std]
3440
version = "1.0"

futures/src/executor/tokio.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
use crate::Executor;
22

33
use futures::Future;
4+
use tokio_new as tokio;
45

56
/// A `tokio` runtime.
67
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]

futures/src/time.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,11 +62,25 @@ where
6262
) -> futures::stream::BoxStream<'static, Self::Output> {
6363
use futures::stream::StreamExt;
6464

65+
#[cfg(feature = "tokio")]
66+
use tokio_new as tokio;
6567
#[cfg(feature = "tokio_old")]
6668
use tokio_old as tokio;
6769

6870
let start = tokio::time::Instant::now() + self.0;
6971

72+
#[cfg(feature = "tokio")]
73+
{
74+
let stream = async_stream::stream! {
75+
let mut interval = tokio::time::interval_at(start, self.0);
76+
loop {
77+
yield interval.tick().await;
78+
}
79+
};
80+
81+
stream.map(|_| std::time::Instant::now()).boxed()
82+
}
83+
#[cfg(feature = "tokio_old")]
7084
tokio::time::interval_at(start, self.0)
7185
.map(|_| std::time::Instant::now())
7286
.boxed()

0 commit comments

Comments
 (0)