Skip to content

Commit ac19c66

Browse files
Keruspeyoshuawuyts
andauthored
Update async-global-executor and add tokio feature for tokio 1.0
Co-authored-by: Yoshua Wuyts <yoshuawuyts+github@gmail.com>
1 parent 4a3f963 commit ac19c66

File tree

5 files changed

+17
-5
lines changed

5 files changed

+17
-5
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview
77

88
## [Unreleased]
99

10+
## Added
11+
12+
- Add `tokio1` feature ([#924](https://github.com/async-rs/async-std/pull/924))
13+
1014
# [1.8.0] - 2020-12-04
1115

1216
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.

Cargo.toml

+2-3
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ default = [
2626
"std",
2727
"async-global-executor",
2828
"async-io",
29-
"blocking",
3029
"futures-lite",
3130
"kv-log-macro",
3231
"log",
@@ -59,6 +58,7 @@ alloc = [
5958
"futures-core/alloc",
6059
"pin-project-lite",
6160
]
61+
tokio1 = ["async-global-executor/tokio"]
6262
tokio02 = ["async-global-executor/tokio02"]
6363
tokio03 = ["async-global-executor/tokio03"]
6464

@@ -83,9 +83,8 @@ surf = { version = "2.0.0", optional = true }
8383

8484

8585
[target.'cfg(not(target_os = "unknown"))'.dependencies]
86-
async-global-executor = { version = "1.4.0", optional = true, features = ["async-io"] }
86+
async-global-executor = { version = "2.0.0", optional = true, features = ["async-io"] }
8787
async-io = { version = "1.0.1", optional = true }
88-
blocking = { version = "1.0.0", optional = true }
8988
futures-lite = { version = "1.0.0", optional = true }
9089
async-process = { version = "1.0.1", optional = true }
9190

src/lib.rs

+9
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,15 @@
213213
//! features = ["attributes"]
214214
//! ```
215215
//!
216+
//! Compatibility with the `tokio` 1.0 runtime is also simultaneously possible
217+
//! using the `tokio1` Cargo feature:
218+
//!
219+
//! ```toml
220+
//! [dependencies.async-std]
221+
//! version = "1.7.0"
222+
//! features = ["tokio1"]
223+
//! ```
224+
//!
216225
//! Compatibility with the `tokio` 0.2 runtime is possible using the `tokio02`
217226
//! Cargo feature:
218227
//!

src/rt/mod.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ pub static RUNTIME: Lazy<Runtime> = Lazy::new(|| {
1212
// Create an executor thread pool.
1313

1414
let thread_name = env::var("ASYNC_STD_THREAD_NAME").unwrap_or_else(|_| "async-std/runtime".to_string());
15-
async_global_executor::init_with_config(async_global_executor::GlobalExecutorConfig::default().with_env_var("ASYNC_STD_THREAD_COUNT").with_thread_name(thread_name));
15+
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()));
1616

1717
Runtime {}
1818
});

src/task/spawn_blocking.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,5 +35,5 @@ where
3535
F: FnOnce() -> T + Send + 'static,
3636
T: Send + 'static,
3737
{
38-
task::spawn(blocking::unblock(f))
38+
task::spawn(async_global_executor::spawn_blocking(f))
3939
}

0 commit comments

Comments
 (0)