parent
244455d8e3
commit
9054e66703
2 changed files with 14 additions and 5 deletions
|
@ -10,6 +10,7 @@ pub(super) struct ConcurrencyLimiter {
|
|||
helper_thread: Option<HelperThread>,
|
||||
state: Arc<Mutex<state::ConcurrencyLimiterState>>,
|
||||
available_token_condvar: Arc<Condvar>,
|
||||
finished: bool,
|
||||
}
|
||||
|
||||
impl ConcurrencyLimiter {
|
||||
|
@ -32,6 +33,7 @@ impl ConcurrencyLimiter {
|
|||
helper_thread: Some(helper_thread),
|
||||
state,
|
||||
available_token_condvar: Arc::new(Condvar::new()),
|
||||
finished: false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -56,16 +58,23 @@ impl ConcurrencyLimiter {
|
|||
let mut state = self.state.lock().unwrap();
|
||||
state.job_already_done();
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ConcurrencyLimiter {
|
||||
fn drop(&mut self) {
|
||||
//
|
||||
pub(crate) fn finished(mut self) {
|
||||
self.helper_thread.take();
|
||||
|
||||
// Assert that all jobs have finished
|
||||
let state = Mutex::get_mut(Arc::get_mut(&mut self.state).unwrap()).unwrap();
|
||||
state.assert_done();
|
||||
|
||||
self.finished = true;
|
||||
}
|
||||
}
|
||||
|
||||
impl Drop for ConcurrencyLimiter {
|
||||
fn drop(&mut self) {
|
||||
if !self.finished && !std::thread::panicking() {
|
||||
panic!("Forgot to call finished() on ConcurrencyLimiter");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -106,7 +106,7 @@ impl OngoingCodegen {
|
|||
}
|
||||
}
|
||||
|
||||
drop(self.concurrency_limiter);
|
||||
self.concurrency_limiter.finished();
|
||||
|
||||
(
|
||||
CodegenResults {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue