Introduce running_with_any_token
closure.
It makes things a little clearer.
This commit is contained in:
parent
3b44f5b0eb
commit
90ce358afa
1 changed files with 10 additions and 7 deletions
|
@ -1300,12 +1300,16 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
let mut main_thread_state = MainThreadState::Idle;
|
||||
|
||||
// How many LLVM worker threads are running while holding a Token. This
|
||||
// *excludes* the LLVM worker thread that the main thread is lending a
|
||||
// Token to (when the main thread is in the `Lending` state).
|
||||
// In other words, the number of LLVM threads is actually equal to
|
||||
// `running + if main_thread_state == Lending { 1 } else { 0 }`.
|
||||
// *excludes* any that the main thread is lending a Token to.
|
||||
let mut running_with_own_token = 0;
|
||||
|
||||
// How many LLVM worker threads are running in total. This *includes*
|
||||
// any that the main thread is lending a Token to.
|
||||
let running_with_any_token = |main_thread_state, running_with_own_token| {
|
||||
running_with_own_token
|
||||
+ if main_thread_state == MainThreadState::Lending { 1 } else { 0 }
|
||||
};
|
||||
|
||||
let mut llvm_start_time: Option<VerboseTimingGuard<'_>> = None;
|
||||
|
||||
// Run the message loop while there's still anything that needs message
|
||||
|
@ -1352,8 +1356,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
}
|
||||
}
|
||||
} else if codegen_state == Completed {
|
||||
if running_with_own_token == 0
|
||||
&& main_thread_state == MainThreadState::Idle
|
||||
if running_with_any_token(main_thread_state, running_with_own_token) == 0
|
||||
&& work_items.is_empty()
|
||||
{
|
||||
// All codegen work is done. Do we have LTO work to do?
|
||||
|
@ -1427,7 +1430,7 @@ fn start_executing_work<B: ExtraBackendMethods>(
|
|||
// Don't queue up any more work if codegen was aborted, we're
|
||||
// just waiting for our existing children to finish.
|
||||
assert!(codegen_state == Aborted);
|
||||
if running_with_own_token == 0 && main_thread_state != MainThreadState::Lending {
|
||||
if running_with_any_token(main_thread_state, running_with_own_token) == 0 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue