Skip to content

Commit

Permalink
Keep better track of finished crates
Browse files Browse the repository at this point in the history
Instead of juggling a few counters let's just keep an explicit counter
of finished packages.
  • Loading branch information
alexcrichton committed May 10, 2019
1 parent 7892472 commit dcd7c48
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
// and then immediately return.
let mut error = None;
let total = self.queue.len();
let mut finished = 0;
loop {
// Dequeue as much work as we can, learning about everything
// possible that can run. Note that this is also the point where we
Expand Down Expand Up @@ -320,7 +321,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
// unnecessarily.
let events: Vec<_> = self.rx.try_iter().collect();
let events = if events.is_empty() {
self.show_progress(total);
self.show_progress(finished, total);
vec![self.rx.recv().unwrap()]
} else {
events
Expand Down Expand Up @@ -355,6 +356,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
// from the `active` map ...
Artifact::All => {
info!("end: {:?}", id);
finished += 1;
self.active.remove(&id).unwrap()
}
// ... otherwise if it hasn't finished we leave it
Expand Down Expand Up @@ -431,8 +433,7 @@ impl<'a, 'cfg> JobQueue<'a, 'cfg> {
}
}

fn show_progress(&mut self, total: usize) {
let count = total - self.queue.len() - self.active.len();
fn show_progress(&mut self, count: usize, total: usize) {
let active_names = self
.active
.values()
Expand Down

0 comments on commit dcd7c48

Please sign in to comment.