ignore: simplify parallel worker initialization

We can just ask the channel whether any work has been loaded. Normally
querying a channel for its length is a strong predictor of bugs, but in
this case, we do it before we ever attempt a `recv`, so it should work.

Kudos to @zsugabubus for suggesting this!
This commit is contained in:
Andrew Gallant 2020-02-20 16:49:54 -05:00
parent da3431b478
commit 109460fce2
No known key found for this signature in database
GPG Key ID: B2E3A4923F8B0D44

View File

@ -1198,7 +1198,6 @@ impl WalkParallel {
let num_pending = Arc::new(AtomicUsize::new(0));
{
let mut visitor = builder.build();
let mut any_work = false;
let mut paths = Vec::new().into_iter();
std::mem::swap(&mut paths, &mut self.paths);
// Send the initial set of root paths to the pool of workers. Note
@ -1241,10 +1240,9 @@ impl WalkParallel {
root_device: root_device,
}))
.unwrap();
any_work = true;
}
// ... but there's no need to start workers if we don't need them.
if !any_work {
if tx.is_empty() {
return;
}
}