Skip to content

Commit 07149e0

Browse files
trans-scheduler: Let main thread take over for other worker.
1 parent c2de81f commit 07149e0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/librustc_trans/back/write.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1356,6 +1356,16 @@ fn start_executing_work(sess: &Session,
13561356
maybe_start_llvm_timer(&item, &mut llvm_start_time);
13571357
main_thread_worker_state = MainThreadWorkerState::LLVMing;
13581358
spawn_work(cgcx, item);
1359+
} else {
1360+
// There is no unstarted work, so let the main thread
1361+
// take over for a running worker. Otherwise the
1362+
// implicit token would just go to waste.
1363+
// We reduce the `running` counter by one. The
1364+
// `tokens.truncate()` below will take care of
1365+
// giving the Token back.
1366+
debug_assert!(running > 0);
1367+
running -= 1;
1368+
main_thread_worker_state = MainThreadWorkerState::LLVMing;
13591369
}
13601370
}
13611371
MainThreadWorkerState::Translating => {

0 commit comments

Comments
 (0)