From b7b1ee31e601afc86017f449574c9e303fae7ed4 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 23 Dec 2020 22:15:14 +0100 Subject: [PATCH 1/6] executor: update to async-global-executor 2.0 mostly configuration api changes Signed-off-by: Marc-Antoine Perennou --- Cargo.toml | 2 +- src/rt/mod.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 93f783ccc..2874145e7 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -83,7 +83,7 @@ surf = { version = "2.0.0", optional = true } [target.'cfg(not(target_os = "unknown"))'.dependencies] -async-global-executor = { version = "1.4.0", optional = true, features = ["async-io"] } +async-global-executor = { version = "2.0.0", optional = true, features = ["async-io"] } async-io = { version = "1.0.1", optional = true } blocking = { version = "1.0.0", optional = true } futures-lite = { version = "1.0.0", optional = true } diff --git a/src/rt/mod.rs b/src/rt/mod.rs index da78d9f89..80f1c4e6b 100644 --- a/src/rt/mod.rs +++ b/src/rt/mod.rs @@ -12,7 +12,7 @@ pub static RUNTIME: Lazy = Lazy::new(|| { // Create an executor thread pool. let thread_name = env::var("ASYNC_STD_THREAD_NAME").unwrap_or_else(|_| "async-std/runtime".to_string()); - async_global_executor::init_with_config(async_global_executor::GlobalExecutorConfig::default().with_env_var("ASYNC_STD_THREAD_COUNT").with_thread_name(thread_name)); + async_global_executor::init_with_config(async_global_executor::GlobalExecutorConfig::default().with_env_var("ASYNC_STD_THREAD_COUNT").with_thread_name_fn(move || thread_name.clone())); Runtime {} }); From 87c9af742a5bd3f129bc5f19c745d29ba0dffa12 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 23 Dec 2020 22:15:41 +0100 Subject: [PATCH 2/6] executor: add tokio feature Signed-off-by: Marc-Antoine Perennou --- CHANGELOG.md | 4 ++++ Cargo.toml | 1 + src/lib.rs | 9 +++++++++ 3 files changed, 14 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e31829df8..97e1fb2d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview ## [Unreleased] +## Added + +- Add `tokio` feature ([#924](https://github.com/async-rs/async-std/pull/924)) + # [1.8.0] - 2020-12-04 This patch introduces `async_std::channel`, a new submodule for our async channels implementation. `channels` have been one of async-std's most requested features, and have existed as "unstable" for the past year. We've been cautious about stabilizing channels, and this caution turned out to be warranted: we realized our channels could hang indefinitely under certain circumstances, and people ended up expressing a need for unbounded channels. diff --git a/Cargo.toml b/Cargo.toml index 2874145e7..7a1e6a835 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -59,6 +59,7 @@ alloc = [ "futures-core/alloc", "pin-project-lite", ] +tokio = ["async-global-executor/tokio"] tokio02 = ["async-global-executor/tokio02"] tokio03 = ["async-global-executor/tokio03"] diff --git a/src/lib.rs b/src/lib.rs index 22495d367..23311c2c0 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,6 +213,15 @@ //! features = ["attributes"] //! ``` //! +//! Compatibility with the `tokio` runtime is also simultaneously possible +//! using the `tokio` Cargo feature: +//! +//! ```toml +//! [dependencies.async-std] +//! version = "1.7.0" +//! features = ["tokio"] +//! ``` +//! //! Compatibility with the `tokio` 0.2 runtime is possible using the `tokio02` //! Cargo feature: //! From f623e855511f23d42f2a5ae7eb562f407161ca50 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Wed, 23 Dec 2020 22:39:25 +0100 Subject: [PATCH 3/6] go through async-global-executor for spawn_blocking Signed-off-by: Marc-Antoine Perennou --- Cargo.toml | 2 -- src/task/spawn_blocking.rs | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 7a1e6a835..1f80ce965 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -26,7 +26,6 @@ default = [ "std", "async-global-executor", "async-io", - "blocking", "futures-lite", "kv-log-macro", "log", @@ -86,7 +85,6 @@ surf = { version = "2.0.0", optional = true } [target.'cfg(not(target_os = "unknown"))'.dependencies] async-global-executor = { version = "2.0.0", optional = true, features = ["async-io"] } async-io = { version = "1.0.1", optional = true } -blocking = { version = "1.0.0", optional = true } futures-lite = { version = "1.0.0", optional = true } async-process = { version = "1.0.1", optional = true } diff --git a/src/task/spawn_blocking.rs b/src/task/spawn_blocking.rs index 8d6f3a51a..3c57a751b 100644 --- a/src/task/spawn_blocking.rs +++ b/src/task/spawn_blocking.rs @@ -35,5 +35,5 @@ where F: FnOnce() -> T + Send + 'static, T: Send + 'static, { - task::spawn(blocking::unblock(f)) + task::spawn(async_global_executor::spawn_blocking(f)) } From a3d69fb67a1c1d35e58d2a247c5cb7ae9eb1529c Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Sun, 3 Jan 2021 10:44:29 +0100 Subject: [PATCH 4/6] rename tokio feature to tokio1 Co-authored-by: Yoshua Wuyts --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 1f80ce965..385d08391 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -58,7 +58,7 @@ alloc = [ "futures-core/alloc", "pin-project-lite", ] -tokio = ["async-global-executor/tokio"] +tokio1 = ["async-global-executor/tokio"] tokio02 = ["async-global-executor/tokio02"] tokio03 = ["async-global-executor/tokio03"] From 9918258829de28b59feddd41b7fa687739262973 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Sun, 3 Jan 2021 10:45:26 +0100 Subject: [PATCH 5/6] option name is tokio1 now --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97e1fb2d1..c16bbf645 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview ## Added -- Add `tokio` feature ([#924](https://github.com/async-rs/async-std/pull/924)) +- Add `tokio1` feature ([#924](https://github.com/async-rs/async-std/pull/924)) # [1.8.0] - 2020-12-04 From 17f4de63d9b65794e503bd4d11a11dc890877166 Mon Sep 17 00:00:00 2001 From: Marc-Antoine Perennou Date: Mon, 4 Jan 2021 10:55:06 +0100 Subject: [PATCH 6/6] Feature name is now tokio1 --- src/lib.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 23311c2c0..9a1c00c10 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -213,13 +213,13 @@ //! features = ["attributes"] //! ``` //! -//! Compatibility with the `tokio` runtime is also simultaneously possible -//! using the `tokio` Cargo feature: +//! Compatibility with the `tokio` 1.0 runtime is also simultaneously possible +//! using the `tokio1` Cargo feature: //! //! ```toml //! [dependencies.async-std] //! version = "1.7.0" -//! features = ["tokio"] +//! features = ["tokio1"] //! ``` //! //! Compatibility with the `tokio` 0.2 runtime is possible using the `tokio02`