Skip to content

Commit

Permalink
chore: update tokio to v1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
yusdacra committed Dec 23, 2020
1 parent f8aef03 commit aa31ef4
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/game_of_life/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ publish = false

[dependencies]
iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
tokio = { version = "0.3", features = ["sync"] }
tokio = { version = "1.0", features = ["sync"] }
itertools = "0.9"
rustc-hash = "1.1"
12 changes: 9 additions & 3 deletions futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ categories = ["gui"]

[features]
thread-pool = ["futures/thread-pool"]
tokio = ["tokio_new", "async-stream"]

[dependencies]
log = "0.4"
Expand All @@ -25,10 +26,15 @@ version = "0.2"
optional = true
features = ["rt-core", "rt-threaded", "time", "stream"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
version = "0.3"
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio_new]
package = "tokio"
version = "1.0"
optional = true
features = ["rt-multi-thread", "time"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-stream]
version = "0.3.0"
optional = true
features = ["rt-multi-thread", "time", "stream"]

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std]
version = "1.0"
Expand Down
1 change: 1 addition & 0 deletions futures/src/executor/tokio.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use crate::Executor;

use futures::Future;
use tokio_new as tokio;

/// A `tokio` runtime.
#[cfg_attr(docsrs, doc(cfg(feature = "tokio")))]
Expand Down
14 changes: 14 additions & 0 deletions futures/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,11 +62,25 @@ where
) -> futures::stream::BoxStream<'static, Self::Output> {
use futures::stream::StreamExt;

#[cfg(feature = "tokio")]
use tokio_new as tokio;
#[cfg(feature = "tokio_old")]
use tokio_old as tokio;

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

#[cfg(feature = "tokio")]
{
let stream = async_stream::stream! {
let mut interval = tokio::time::interval_at(start, self.0);
loop {
yield interval.tick().await;
}
};

stream.map(|_| std::time::Instant::now()).boxed()
}
#[cfg(feature = "tokio_old")]
tokio::time::interval_at(start, self.0)
.map(|_| std::time::Instant::now())
.boxed()
Expand Down

0 comments on commit aa31ef4

Please sign in to comment.