]> git.proxmox.com Git - cargo.git/commitdiff
Pop thread token requests from the front
authorMark Rousskov <mark.simulacrum@gmail.com>
Thu, 16 Jan 2020 23:28:03 +0000 (18:28 -0500)
committerMark Rousskov <mark.simulacrum@gmail.com>
Wed, 22 Jan 2020 19:20:41 +0000 (14:20 -0500)
This ensures we have a first come first served ordering for both thread and
process tokens.

src/cargo/core/compiler/job_queue.rs

index 4bde576dd2bbcd9fd414c9b6cf80678464f5f565..5411579f1b064a69df54767bdcc29a7975b181bd 100644 (file)
@@ -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)