From: Mark Rousskov Date: Thu, 16 Jan 2020 23:28:03 +0000 (-0500) Subject: Pop thread token requests from the front X-Git-Url: https://git.proxmox.com/?a=commitdiff_plain;h=1988dd92b8c5e0f04a415973e7d42277ed41bdc1;p=cargo.git Pop thread token requests from the front This ensures we have a first come first served ordering for both thread and process tokens. --- diff --git a/src/cargo/core/compiler/job_queue.rs b/src/cargo/core/compiler/job_queue.rs index 4bde576dd..5411579f1 100644 --- a/src/cargo/core/compiler/job_queue.rs +++ b/src/cargo/core/compiler/job_queue.rs @@ -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)