mirror of
https://github.com/BurntSushi/ripgrep.git
synced 2024-12-12 19:18:24 +02:00
[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.
This commit is contained in:
parent
9ce0484670
commit
9f1aae64f8
@ -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(),
|
||||
|
Loading…
Reference in New Issue
Block a user