workers(0) will default to num_cpus

This commit is contained in:
adrian-wechner 2020-07-23 19:55:53 +02:00
parent 8ace9264b7
commit 3702fe3c05
2 changed files with 11 additions and 2 deletions

View File

@ -1,5 +1,11 @@
# Changes
## Unreleased
### Changed
* workers(0) defaults to num_cpus::get()
## [1.0.3] - 2020-05-19
### Changed

View File

@ -72,9 +72,12 @@ impl ServerBuilder {
/// Set number of workers to start.
///
/// By default server uses number of available logical cpu as workers
/// count.
/// count. Explicitly setting 0 will also default.
pub fn workers(mut self, num: usize) -> Self {
self.threads = num;
self.threads = match num {
0 => num_cpus::get(),
_ => num,
};
self
}