| 1 | //! Minimum supported Rust version: 1.28 |
| 2 | |
| 3 | use stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::numrust-analyzer cargo std https://github.com/rust-lang/rust/library/std num/::NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#; |
| 4 | |
| 5 | #[cfg_attr(any(target_os = "linux", target_os = "android"), path = "linux.rs")] |
| 6 | #[cfg_attr(target_os = "freebsd", path = "freebsd.rs")] |
| 7 | #[cfg_attr(any(target_os = "macos", target_os = "ios"), path = "apple.rs")] |
| 8 | #[cfg_attr(target_os = "aix", path = "aix.rs")] |
| 9 | mod imprust-analyzer cargo num_threads 0.1.7 imp/; |
| 10 | |
| 11 | /// Obtain the number of threads currently part of the active process. Returns `None` if the number |
| 12 | /// of threads cannot be determined. |
| 13 | pub fn num_threadsrust-analyzer cargo num_threads 0.1.7 num_threads().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<NonZeroUsizerust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/NonZeroUsize#> { |
| 14 | imprust-analyzer cargo num_threads 0.1.7 imp/::num_threadsrust-analyzer cargo num_threads 0.1.7 imp/num_threads().() |
| 15 | } |
| 16 | |
| 17 | /// Determine if the current process is single-threaded. Returns `None` if the number of threads |
| 18 | /// cannot be determined. |
| 19 | pub fn is_single_threadedrust-analyzer cargo num_threads 0.1.7 is_single_threaded().() -> Optionrust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/Option#<bool> { |
| 20 | num_threadsrust-analyzer cargo num_threads 0.1.7 num_threads().().maprust-analyzer cargo core https://github.com/rust-lang/rust/library/core option/impl#[`Option<T>`]map().(|n| n.getrust-analyzer cargo core https://github.com/rust-lang/rust/library/core num/nonzero/impl#[`NonZero<T>`]get().() rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().==rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq(). rust-analyzer cargo core https://github.com/rust-lang/rust/library/core cmp/impls/impl#[usize][`PartialEq<Self>`]eq().1) |
| 21 | } |