Remove support for old tokio crate
This commit is contained in:
parent
1a31aefab4
commit
67f878b890
9 changed files with 15 additions and 80 deletions
|
|
@ -38,8 +38,6 @@ glow_default_system_font = ["iced_glow/default_system_font"]
|
||||||
debug = ["iced_winit/debug"]
|
debug = ["iced_winit/debug"]
|
||||||
# Enables `tokio` as the `executor::Default` on native platforms
|
# Enables `tokio` as the `executor::Default` on native platforms
|
||||||
tokio = ["iced_futures/tokio"]
|
tokio = ["iced_futures/tokio"]
|
||||||
# Enables old `tokio` (0.2) as the `executor::Default` on native platforms
|
|
||||||
tokio_old = ["iced_futures/tokio_old"]
|
|
||||||
# Enables `async-std` as the `executor::Default` on native platforms
|
# Enables `async-std` as the `executor::Default` on native platforms
|
||||||
async-std = ["iced_futures/async-std"]
|
async-std = ["iced_futures/async-std"]
|
||||||
# Enables `smol` as the `executor::Default` on native platforms
|
# Enables `smol` as the `executor::Default` on native platforms
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@ edition = "2018"
|
||||||
publish = false
|
publish = false
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
iced = { path = "../..", features = ["image", "debug", "tokio_old"] }
|
iced = { path = "../..", features = ["image", "debug", "tokio"] }
|
||||||
serde_json = "1.0"
|
serde_json = "1.0"
|
||||||
|
|
||||||
[dependencies.serde]
|
[dependencies.serde]
|
||||||
|
|
@ -14,7 +14,7 @@ version = "1.0"
|
||||||
features = ["derive"]
|
features = ["derive"]
|
||||||
|
|
||||||
[dependencies.reqwest]
|
[dependencies.reqwest]
|
||||||
version = "0.10.2"
|
version = "0.11"
|
||||||
features = ["json"]
|
features = ["json"]
|
||||||
|
|
||||||
[dependencies.rand]
|
[dependencies.rand]
|
||||||
|
|
|
||||||
|
|
@ -19,12 +19,6 @@ log = "0.4"
|
||||||
[dependencies.futures]
|
[dependencies.futures]
|
||||||
version = "0.3"
|
version = "0.3"
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio_old]
|
|
||||||
package = "tokio"
|
|
||||||
version = "0.2"
|
|
||||||
optional = true
|
|
||||||
features = ["rt-core", "rt-threaded", "time", "stream"]
|
|
||||||
|
|
||||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
|
[target.'cfg(not(target_arch = "wasm32"))'.dependencies.tokio]
|
||||||
package = "tokio"
|
package = "tokio"
|
||||||
version = "1.0"
|
version = "1.0"
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,6 @@ mod thread_pool;
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
|
||||||
mod tokio;
|
mod tokio;
|
||||||
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio_old"))]
|
|
||||||
mod tokio_old;
|
|
||||||
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
|
||||||
mod async_std;
|
mod async_std;
|
||||||
|
|
||||||
|
|
@ -27,9 +24,6 @@ pub use thread_pool::ThreadPool;
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio"))]
|
||||||
pub use self::tokio::Tokio;
|
pub use self::tokio::Tokio;
|
||||||
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "tokio_old"))]
|
|
||||||
pub use self::tokio_old::TokioOld;
|
|
||||||
|
|
||||||
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
|
#[cfg(all(not(target_arch = "wasm32"), feature = "async-std"))]
|
||||||
pub use self::async_std::AsyncStd;
|
pub use self::async_std::AsyncStd;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +0,0 @@
|
||||||
use crate::Executor;
|
|
||||||
|
|
||||||
use futures::Future;
|
|
||||||
|
|
||||||
/// An old `tokio` runtime.
|
|
||||||
#[cfg_attr(docsrs, doc(cfg(feature = "tokio_old")))]
|
|
||||||
pub type TokioOld = tokio_old::runtime::Runtime;
|
|
||||||
|
|
||||||
impl Executor for TokioOld {
|
|
||||||
fn new() -> Result<Self, futures::io::Error> {
|
|
||||||
tokio_old::runtime::Runtime::new()
|
|
||||||
}
|
|
||||||
|
|
||||||
fn spawn(&self, future: impl Future<Output = ()> + Send + 'static) {
|
|
||||||
let _ = tokio_old::runtime::Runtime::spawn(self, future);
|
|
||||||
}
|
|
||||||
|
|
||||||
fn enter<R>(&self, f: impl FnOnce() -> R) -> R {
|
|
||||||
tokio_old::runtime::Runtime::enter(self, f)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -20,12 +20,7 @@ pub mod executor;
|
||||||
pub mod subscription;
|
pub mod subscription;
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(
|
any(feature = "tokio", feature = "async-std", feature = "smol"),
|
||||||
feature = "tokio",
|
|
||||||
feature = "tokio_old",
|
|
||||||
feature = "async-std",
|
|
||||||
feature = "smol"
|
|
||||||
),
|
|
||||||
not(target_arch = "wasm32")
|
not(target_arch = "wasm32")
|
||||||
))]
|
))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
|
|
|
||||||
|
|
@ -14,7 +14,7 @@ pub fn every<H: std::hash::Hasher, E>(
|
||||||
struct Every(std::time::Duration);
|
struct Every(std::time::Duration);
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
not(any(feature = "tokio_old", feature = "tokio", feature = "async-std")),
|
not(any(feature = "tokio", feature = "async-std")),
|
||||||
feature = "smol"
|
feature = "smol"
|
||||||
))]
|
))]
|
||||||
impl<H, E> subscription::Recipe<H, E> for Every
|
impl<H, E> subscription::Recipe<H, E> for Every
|
||||||
|
|
@ -67,7 +67,7 @@ where
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(feature = "tokio", feature = "tokio_old"),
|
feature = "tokio",
|
||||||
not(any(feature = "async-std", feature = "smol"))
|
not(any(feature = "async-std", feature = "smol"))
|
||||||
))]
|
))]
|
||||||
impl<H, E> subscription::Recipe<H, E> for Every
|
impl<H, E> subscription::Recipe<H, E> for Every
|
||||||
|
|
@ -89,23 +89,15 @@ where
|
||||||
) -> futures::stream::BoxStream<'static, Self::Output> {
|
) -> futures::stream::BoxStream<'static, Self::Output> {
|
||||||
use futures::stream::StreamExt;
|
use futures::stream::StreamExt;
|
||||||
|
|
||||||
#[cfg(feature = "tokio_old")]
|
|
||||||
use tokio_old as tokio;
|
|
||||||
|
|
||||||
let start = tokio::time::Instant::now() + self.0;
|
let start = tokio::time::Instant::now() + self.0;
|
||||||
|
|
||||||
let stream = {
|
let stream = {
|
||||||
#[cfg(feature = "tokio")]
|
futures::stream::unfold(
|
||||||
{
|
tokio::time::interval_at(start, self.0),
|
||||||
futures::stream::unfold(
|
|mut interval| async move {
|
||||||
tokio::time::interval_at(start, self.0),
|
Some((interval.tick().await, interval))
|
||||||
|mut interval| async move {
|
},
|
||||||
Some((interval.tick().await, interval))
|
)
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
|
||||||
#[cfg(feature = "tokio_old")]
|
|
||||||
tokio::time::interval_at(start, self.0)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
stream.map(tokio::time::Instant::into_std).boxed()
|
stream.map(tokio::time::Instant::into_std).boxed()
|
||||||
|
|
|
||||||
|
|
@ -7,30 +7,19 @@ pub use platform::Default;
|
||||||
mod platform {
|
mod platform {
|
||||||
use iced_futures::{executor, futures};
|
use iced_futures::{executor, futures};
|
||||||
|
|
||||||
#[cfg(feature = "tokio_old")]
|
#[cfg(feature = "tokio")]
|
||||||
type Executor = executor::TokioOld;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "tokio", not(feature = "tokio_old")))]
|
|
||||||
type Executor = executor::Tokio;
|
type Executor = executor::Tokio;
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(feature = "async-std", not(feature = "tokio"),))]
|
||||||
feature = "async-std",
|
|
||||||
not(any(feature = "tokio_old", feature = "tokio")),
|
|
||||||
))]
|
|
||||||
type Executor = executor::AsyncStd;
|
type Executor = executor::AsyncStd;
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
feature = "smol",
|
feature = "smol",
|
||||||
not(any(
|
not(any(feature = "tokio", feature = "async-std")),
|
||||||
feature = "tokio_old",
|
|
||||||
feature = "tokio",
|
|
||||||
feature = "async-std"
|
|
||||||
)),
|
|
||||||
))]
|
))]
|
||||||
type Executor = executor::Smol;
|
type Executor = executor::Smol;
|
||||||
|
|
||||||
#[cfg(not(any(
|
#[cfg(not(any(
|
||||||
feature = "tokio_old",
|
|
||||||
feature = "tokio",
|
feature = "tokio",
|
||||||
feature = "async-std",
|
feature = "async-std",
|
||||||
feature = "smol",
|
feature = "smol",
|
||||||
|
|
|
||||||
|
|
@ -195,19 +195,13 @@ pub mod widget;
|
||||||
pub mod window;
|
pub mod window;
|
||||||
|
|
||||||
#[cfg(all(
|
#[cfg(all(
|
||||||
any(
|
any(feature = "tokio", feature = "async-std", feature = "smol"),
|
||||||
feature = "tokio",
|
|
||||||
feature = "tokio_old",
|
|
||||||
feature = "async-std",
|
|
||||||
feature = "smol"
|
|
||||||
),
|
|
||||||
not(target_arch = "wasm32")
|
not(target_arch = "wasm32")
|
||||||
))]
|
))]
|
||||||
#[cfg_attr(
|
#[cfg_attr(
|
||||||
docsrs,
|
docsrs,
|
||||||
doc(cfg(any(
|
doc(cfg(any(
|
||||||
feature = "tokio",
|
feature = "tokio",
|
||||||
feature = "tokio_old",
|
|
||||||
feature = "async-std"
|
feature = "async-std"
|
||||||
feature = "smol"
|
feature = "smol"
|
||||||
)))
|
)))
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue