Skip to content

Commit

Permalink
Update async-global-executor and add tokio feature for tokio 1.0
Browse files Browse the repository at this point in the history
Co-authored-by: Yoshua Wuyts <[email protected]>
  • Loading branch information
Keruspe and yoshuawuyts authored Jan 13, 2021
1 parent 4a3f963 commit ac19c66
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://book.async.rs/overview

## [Unreleased]

## Added

- Add `tokio1` 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.
Expand Down
5 changes: 2 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ default = [
"std",
"async-global-executor",
"async-io",
"blocking",
"futures-lite",
"kv-log-macro",
"log",
Expand Down Expand Up @@ -59,6 +58,7 @@ alloc = [
"futures-core/alloc",
"pin-project-lite",
]
tokio1 = ["async-global-executor/tokio"]
tokio02 = ["async-global-executor/tokio02"]
tokio03 = ["async-global-executor/tokio03"]

Expand All @@ -83,9 +83,8 @@ 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 }
async-process = { version = "1.0.1", optional = true }

Expand Down
9 changes: 9 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,15 @@
//! features = ["attributes"]
//! ```
//!
//! 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 = ["tokio1"]
//! ```
//!
//! Compatibility with the `tokio` 0.2 runtime is possible using the `tokio02`
//! Cargo feature:
//!
Expand Down
2 changes: 1 addition & 1 deletion src/rt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub static RUNTIME: Lazy<Runtime> = 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 {}
});
2 changes: 1 addition & 1 deletion src/task/spawn_blocking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}

0 comments on commit ac19c66

Please sign in to comment.