Skip to content

Commit

Permalink
chore: update tokio to v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
yusdacra committed Jan 4, 2021
1 parent f8aef03 commit daa9dbf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 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"
5 changes: 3 additions & 2 deletions futures/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@ optional = true
features = ["rt-core", "rt-threaded", "time", "stream"]

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

[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std]
version = "1.0"
Expand Down
18 changes: 15 additions & 3 deletions futures/src/time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,20 @@ where

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

tokio::time::interval_at(start, self.0)
.map(|_| std::time::Instant::now())
.boxed()
let stream = {
#[cfg(feature = "tokio")]
{
futures::stream::unfold(
tokio::time::interval_at(start, self.0),
|mut interval| async move {
Some((interval.tick().await, interval))
},
)
}
#[cfg(feature = "tokio_old")]
tokio::time::interval_at(start, self.0)
};

stream.map(|_| std::time::Instant::now()).boxed()
}
}

0 comments on commit daa9dbf

Please sign in to comment.