mirror of
https://github.com/Cuprate/cuprate.git
synced 2024-12-22 19:49:28 +00:00
helper: NON_ZERO_USIZE_1
-> NonZeroUsize::MIN
(#70)
thread: `NON_ZERO_USIZE_1` -> `NonZeroUsize::MIN`
This commit is contained in:
parent
e287ea1d84
commit
083c0515d2
1 changed files with 1 additions and 8 deletions
|
@ -5,13 +5,6 @@
|
||||||
//---------------------------------------------------------------------------------------------------- Use
|
//---------------------------------------------------------------------------------------------------- Use
|
||||||
use std::{cmp::max, num::NonZeroUsize};
|
use std::{cmp::max, num::NonZeroUsize};
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Constants
|
|
||||||
// FIXME: switch to `.unwrap()` when const stablized
|
|
||||||
const NON_ZERO_USIZE_1: NonZeroUsize = match NonZeroUsize::new(1) {
|
|
||||||
Some(t) => t,
|
|
||||||
_ => panic!(),
|
|
||||||
};
|
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------- Thread Count & Percent
|
//---------------------------------------------------------------------------------------------------- Thread Count & Percent
|
||||||
#[allow(non_snake_case)]
|
#[allow(non_snake_case)]
|
||||||
/// Get the total amount of system threads.
|
/// Get the total amount of system threads.
|
||||||
|
@ -21,7 +14,7 @@ const NON_ZERO_USIZE_1: NonZeroUsize = match NonZeroUsize::new(1) {
|
||||||
/// assert!(threads().get() >= 1);
|
/// assert!(threads().get() >= 1);
|
||||||
/// ```
|
/// ```
|
||||||
pub fn threads() -> NonZeroUsize {
|
pub fn threads() -> NonZeroUsize {
|
||||||
std::thread::available_parallelism().unwrap_or(NON_ZERO_USIZE_1)
|
std::thread::available_parallelism().unwrap_or(NonZeroUsize::MIN)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implement a function for the various
|
// Implement a function for the various
|
||||||
|
|
Loading…
Reference in a new issue