Merge commit '3270432f4b0583104c8b9b6f695bf97d6bbf3ac2' into sync_cg_clif-2024-05-13
This commit is contained in:
@@ -6,7 +6,7 @@ use rustc_session::Session;
|
||||
// FIXME don't panic when a worker thread panics
|
||||
|
||||
pub(super) struct ConcurrencyLimiter {
|
||||
helper_thread: Option<HelperThread>,
|
||||
helper_thread: Option<Mutex<HelperThread>>,
|
||||
state: Arc<Mutex<state::ConcurrencyLimiterState>>,
|
||||
available_token_condvar: Arc<Condvar>,
|
||||
finished: bool,
|
||||
@@ -39,14 +39,14 @@ impl ConcurrencyLimiter {
|
||||
})
|
||||
.unwrap();
|
||||
ConcurrencyLimiter {
|
||||
helper_thread: Some(helper_thread),
|
||||
helper_thread: Some(Mutex::new(helper_thread)),
|
||||
state,
|
||||
available_token_condvar,
|
||||
finished: false,
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn acquire(&mut self, dcx: &rustc_errors::DiagCtxt) -> ConcurrencyLimiterToken {
|
||||
pub(super) fn acquire(&self, dcx: &rustc_errors::DiagCtxt) -> ConcurrencyLimiterToken {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
loop {
|
||||
state.assert_invariants();
|
||||
@@ -73,16 +73,11 @@ impl ConcurrencyLimiter {
|
||||
}
|
||||
}
|
||||
|
||||
self.helper_thread.as_mut().unwrap().request_token();
|
||||
self.helper_thread.as_ref().unwrap().lock().unwrap().request_token();
|
||||
state = self.available_token_condvar.wait(state).unwrap();
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn job_already_done(&mut self) {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
state.job_already_done();
|
||||
}
|
||||
|
||||
pub(crate) fn finished(mut self) {
|
||||
self.helper_thread.take();
|
||||
|
||||
@@ -190,14 +185,6 @@ mod state {
|
||||
self.assert_invariants();
|
||||
}
|
||||
|
||||
pub(super) fn job_already_done(&mut self) {
|
||||
self.assert_invariants();
|
||||
self.pending_jobs -= 1;
|
||||
self.assert_invariants();
|
||||
self.drop_excess_capacity();
|
||||
self.assert_invariants();
|
||||
}
|
||||
|
||||
pub(super) fn poison(&mut self, error: String) {
|
||||
self.poisoned = true;
|
||||
self.stored_error = Some(error);
|
||||
|
||||
Reference in New Issue
Block a user