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

Rename std::thread::available_conccurrency to std::thread::available_parallelism #89324

Merged
merged 2 commits into from
Oct 6, 2021
Merged
Show file tree
Hide file tree
Changes from all 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
2 changes: 1 addition & 1 deletion library/std/src/sys/hermit/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ impl Thread {
}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/sgx/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ impl Thread {
}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unix/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl Drop for Thread {
}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
cfg_if::cfg_if! {
if #[cfg(any(
target_os = "android",
Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/unsupported/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ impl Thread {
}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/wasi/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ impl Thread {
}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/wasm/atomics/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Thread {
pub fn join(self) {}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
unsupported()
}

Expand Down
2 changes: 1 addition & 1 deletion library/std/src/sys/windows/thread.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ impl Thread {
}
}

pub fn available_concurrency() -> io::Result<NonZeroUsize> {
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
let res = unsafe {
let mut sysinfo: c::SYSTEM_INFO = crate::mem::zeroed();
c::GetSystemInfo(&mut sysinfo);
Expand Down
12 changes: 7 additions & 5 deletions library/std/src/thread/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1455,12 +1455,14 @@ fn _assert_sync_and_send() {
///
/// ```
/// # #![allow(dead_code)]
/// #![feature(available_concurrency)]
/// #![feature(available_parallelism)]
/// use std::thread;
///
/// let count = thread::available_concurrency().map(|n| n.get()).unwrap_or(1);
/// let count = thread::available_parallelism().map(|n| n.get()).unwrap_or(1);
/// ```
#[unstable(feature = "available_concurrency", issue = "74479")]
pub fn available_concurrency() -> io::Result<NonZeroUsize> {
imp::available_concurrency()
#[doc(alias = "hardware_concurrency")] // Alias for C++ `std::thread::hardware_concurrency`.
#[doc(alias = "available_concurrency")] // Alias for a name we gave this API on unstable.
#[unstable(feature = "available_parallelism", issue = "74479")]
pub fn available_parallelism() -> io::Result<NonZeroUsize> {
imp::available_parallelism()
}
2 changes: 1 addition & 1 deletion library/test/src/helpers/concurrency.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ pub fn get_concurrency() -> usize {
_ => panic!("RUST_TEST_THREADS is `{}`, should be a positive integer.", value),
}
} else {
thread::available_concurrency().map(|n| n.get()).unwrap_or(1)
thread::available_parallelism().map(|n| n.get()).unwrap_or(1)
}
}
2 changes: 1 addition & 1 deletion library/test/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#![feature(libc)]
#![feature(rustc_private)]
#![feature(nll)]
#![feature(available_concurrency)]
#![feature(available_parallelism)]
#![feature(bench_black_box)]
#![feature(internal_output_capture)]
#![feature(panic_unwind)]
Expand Down
4 changes: 2 additions & 2 deletions src/doc/rustc/src/tests/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ The following options affect how tests are executed.

Sets the number of threads to use for running tests in parallel. By default,
uses the amount of concurrency available on the hardware as indicated by
[`available_concurrency`].
[`available_parallelism`].

This can also be specified with the `RUST_TEST_THREADS` environment variable.

Expand Down Expand Up @@ -265,7 +265,7 @@ Experimental support for using custom test harnesses is available on the

[`--test` option]: ../command-line-arguments.md#option-test
[`-Z panic-abort-tests`]: https://github.com/rust-lang/rust/issues/67650
[`available_concurrency`]: ../../std/thread/fn.available_concurrency.html
[`available_parallelism`]: ../../std/thread/fn.available_parallelism.html
[`cargo test`]: ../../cargo/commands/cargo-test.html
[`libtest`]: ../../test/index.html
[`main` function]: ../../reference/crates-and-source-files.html#main-functions
Expand Down