]> git.lizzy.rs Git - rust.git/commit - src/tools/rust-analyzer
Rollup merge of #89670 - yoshuawuyts:available-parallelism-docs, r=joshtriplett
authorMatthias Krüger <matthias.krueger@famsik.de>
Wed, 13 Oct 2021 20:51:01 +0000 (22:51 +0200)
committerGitHub <noreply@github.com>
Wed, 13 Oct 2021 20:51:01 +0000 (22:51 +0200)
commit06110c0c466e46d48d0bf01b43cf0ad5a01391b2
treebb8d926d642e7221f647d23455c0994caa562fde
parentefac68b93cfac0aa7062169f3b041661fbbdbdbd
parent21429eda2de59327881359b083e97f5fef58f17a
Rollup merge of #89670 - yoshuawuyts:available-parallelism-docs, r=joshtriplett

Improve `std::thread::available_parallelism` docs

_Tracking issue: https://github.com/rust-lang/rust/issues/74479_

This PR reworks the documentation of `std::thread::available_parallelism`, as requested [here](https://github.com/rust-lang/rust/pull/89324#issuecomment-934343254).

## Changes

The following changes are made:

- We've removed prior mentions of "hardware threads" and instead centers the docs around "parallelism" as a resource available to a program.
- We now provide examples of when `available_parallelism` may return numbers that differ from the number of CPU cores in the host machine.
- We now mention that the amount of available parallelism may change over time.
- We make note of which platform components we don't take into account which more advanced users may want to take note of.
- The example has been updated, which should be a bit easier to use.
- We've added a docs alias to `num-cpus` which provides similar functionality to `available_parallelism`, and is one of the most popular crates on crates.io.

---

Thanks!

r? `@BurntSushi`
library/std/src/thread/mod.rs