detect static method
int
detect({
- required ProcFileReader reader,
- required int numberOfProcessors,
- required bool isLinux,
Works out the usable CPUs from the files the reader gives.
Tests pass a fake reader.
Implementation
static int detect({
required ProcFileReader reader,
required int numberOfProcessors,
required bool isLinux,
}) {
int count = numberOfProcessors;
if (!isLinux) {
return count < 1 ? 1 : count;
}
count = _min(count, parseCpusAllowed(reader.read('/proc/self/status')));
count = _min(count, _quota(reader));
return count < 1 ? 1 : count;
}