pub enum ThreadCount {
Auto,
Fixed(usize),
Fraction(f64),
}Expand description
How many worker threads ComputeBackend::CpuMulti should use.
Mirrors the established shape in boon-lay’s and outram-mc-libs’s own
compute modules so the workspace has one vocabulary for this rather than
three.
§Units
Dimensionless counts. Fraction is a pure ratio.
Variants§
Auto
Every logical core, via std::thread::available_parallelism, falling
back to 1 if the query fails. The default.
Fixed(usize)
An explicit worker count, clamped up to a minimum of 1.
Fraction(f64)
A fraction of the available logical cores, e.g. 0.5 for half. The
product is rounded to nearest and clamped to at least 1. A non-finite
or non-positive fraction clamps to 1 rather than panicking.
Implementations§
Source§impl ThreadCount
impl ThreadCount
Sourcepub fn resolve(self) -> usize
pub fn resolve(self) -> usize
Resolve to a concrete worker-thread count, always >= 1.
§Returns
A thread count in [1, usize::MAX]. Never zero, so it is always safe
to hand to a thread-pool builder.
§Example
use outram_foam_basic_lib::compute::ThreadCount;
assert_eq!(ThreadCount::Fixed(0).resolve(), 1); // clamped, not a panic
assert_eq!(ThreadCount::Fixed(3).resolve(), 3);
assert!(ThreadCount::Auto.resolve() >= 1);