Merge pull request #672 from yusdacra/tokio-1.0

Update tokio to v1.0
This commit is contained in:
Héctor Ramón 2021-01-04 23:33:09 +01:00 committed by GitHub
commit 80a490ebb9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 6 deletions

View File

@ -7,6 +7,6 @@ publish = false
[dependencies] [dependencies]
iced = { path = "../..", features = ["canvas", "tokio", "debug"] } iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
tokio = { version = "0.3", features = ["sync"] } tokio = { version = "1.0", features = ["sync"] }
itertools = "0.9" itertools = "0.9"
rustc-hash = "1.1" rustc-hash = "1.1"

View File

@ -26,9 +26,10 @@ optional = true
features = ["rt-core", "rt-threaded", "time", "stream"] features = ["rt-core", "rt-threaded", "time", "stream"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
version = "0.3" package = "tokio"
version = "1.0"
optional = true optional = true
features = ["rt-multi-thread", "time", "stream"] features = ["rt", "rt-multi-thread", "time"]
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std] [target.'cfg(not(target_arch = "wasm32"))'.dependencies.async-std]
version = "1.0" version = "1.0"

View File

@ -67,8 +67,20 @@ where
let start = tokio::time::Instant::now() + self.0; let start = tokio::time::Instant::now() + self.0;
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) tokio::time::interval_at(start, self.0)
.map(|_| std::time::Instant::now()) };
.boxed()
stream.map(tokio::time::Instant::into_std).boxed()
} }
} }