Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update async-global-executor and add tokio feature for tokio 1.0 #924

Merged
merged 6 commits into from
Jan 13, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 `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.
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",
]
tokio = ["async-global-executor/tokio"]
Keruspe marked this conversation as resolved.
Show resolved Hide resolved
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` runtime is also simultaneously possible
//! using the `tokio` Cargo feature:
//!
//! ```toml
//! [dependencies.async-std]
//! version = "1.7.0"
//! features = ["tokio"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs updating still

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh, fair enough

//! ```
//!
//! 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))
}