Skip to content

Commit

Permalink
Pop thread token requests from the front
Browse files Browse the repository at this point in the history
This ensures we have a first come first served ordering for both thread and
process tokens.
  • Loading branch information
Mark-Simulacrum committed Jan 22, 2020
1 parent 5a9af54 commit 1988dd9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/cargo/core/compiler/job_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,10 @@ impl<'a, 'cfg> DrainState<'a, 'cfg> {
// If we managed to acquire some extra tokens, send them off to a waiting rustc.
let extra_tokens = self.tokens.len() - (self.active.len() - 1);
for _ in 0..extra_tokens {
if let Some((id, client)) = self.to_send_clients.pop() {
if !self.to_send_clients.is_empty() {
// remove from the front so we grant the token to the oldest
// waiter
let (id, client) = self.to_send_clients.remove(0);
let token = self.tokens.pop().expect("an extra token");
self.rustc_tokens
.entry(id)
Expand Down

0 comments on commit 1988dd9

Please sign in to comment.