diff options
author | Bharath M R <catchmrbharath@gmail.com> | 2016-09-24 17:29:14 -0700 |
---|---|---|
committer | Bharath M R <catchmrbharath@gmail.com> | 2016-09-24 19:48:26 -0700 |
commit | 9f1aae64f85b69a4b495498b5c802942a4c39143 (patch) | |
tree | 6d9b82f41fe15baf0981bb15a25d1e0506f22a1d /src/main.rs | |
parent | 9ce0484670c9d63c5ac16bb52d2fa026c58e7a37 (diff) |
[Fixes #46] Use 1 less worker thread than number of threads
The main thread does directory traversal. Hence
number of threads = main Thread + number of worker threads.
We should have atleast one worker thread.
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/src/main.rs b/src/main.rs index e4f4b4f3..314c88dc 100644 --- a/src/main.rs +++ b/src/main.rs @@ -28,6 +28,7 @@ use std::process; use std::result; use std::sync::{Arc, Mutex}; use std::thread; +use std::cmp; use deque::{Stealer, Stolen}; use grep::Grep; @@ -102,7 +103,7 @@ fn run(args: Args) -> Result<u64> { let workq = { let (workq, stealer) = deque::new(); - for _ in 0..args.threads() { + for _ in 0..cmp::max(1, args.threads() - 1) { let worker = MultiWorker { chan_work: stealer.clone(), out: out.clone(), |