1
Fork 0

Tweak a loop condition.

This loop condition involves `codegen_state`, `work_items`, and
`running_with_own_token`. But the body of the loop cannot modify
`codegen_state`, so repeatedly checking it is unnecessary.
This commit is contained in:
Nicholas Nethercote 2023-07-21 09:48:57 +10:00
parent d21d31cce7
commit 179bf19813

View file

@ -1431,14 +1431,18 @@ fn start_executing_work<B: ExtraBackendMethods>(
// Spin up what work we can, only doing this while we've got available // Spin up what work we can, only doing this while we've got available
// parallelism slots and work left to spawn. // parallelism slots and work left to spawn.
while codegen_state != Aborted if codegen_state != Aborted {
&& !work_items.is_empty() while !work_items.is_empty() && running_with_own_token < tokens.len() {
&& running_with_own_token < tokens.len()
{
let (item, _) = work_items.pop().unwrap(); let (item, _) = work_items.pop().unwrap();
spawn_work(&cgcx, &mut llvm_start_time, get_worker_id(&mut free_worker_ids), item); spawn_work(
&cgcx,
&mut llvm_start_time,
get_worker_id(&mut free_worker_ids),
item,
);
running_with_own_token += 1; running_with_own_token += 1;
} }
}
// Relinquish accidentally acquired extra tokens. // Relinquish accidentally acquired extra tokens.
tokens.truncate(running_with_own_token); tokens.truncate(running_with_own_token);