File tree 2 files changed +14
-5
lines changed
2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ pub(super) struct ConcurrencyLimiter {
10
10
helper_thread : Option < HelperThread > ,
11
11
state : Arc < Mutex < state:: ConcurrencyLimiterState > > ,
12
12
available_token_condvar : Arc < Condvar > ,
13
+ finished : bool ,
13
14
}
14
15
15
16
impl ConcurrencyLimiter {
@@ -32,6 +33,7 @@ impl ConcurrencyLimiter {
32
33
helper_thread : Some ( helper_thread) ,
33
34
state,
34
35
available_token_condvar : Arc :: new ( Condvar :: new ( ) ) ,
36
+ finished : false ,
35
37
}
36
38
}
37
39
@@ -56,16 +58,23 @@ impl ConcurrencyLimiter {
56
58
let mut state = self . state . lock ( ) . unwrap ( ) ;
57
59
state. job_already_done ( ) ;
58
60
}
59
- }
60
61
61
- impl Drop for ConcurrencyLimiter {
62
- fn drop ( & mut self ) {
63
- //
62
+ pub ( crate ) fn finished ( mut self ) {
64
63
self . helper_thread . take ( ) ;
65
64
66
65
// Assert that all jobs have finished
67
66
let state = Mutex :: get_mut ( Arc :: get_mut ( & mut self . state ) . unwrap ( ) ) . unwrap ( ) ;
68
67
state. assert_done ( ) ;
68
+
69
+ self . finished = true ;
70
+ }
71
+ }
72
+
73
+ impl Drop for ConcurrencyLimiter {
74
+ fn drop ( & mut self ) {
75
+ if !self . finished && !std:: thread:: panicking ( ) {
76
+ panic ! ( "Forgot to call finished() on ConcurrencyLimiter" ) ;
77
+ }
69
78
}
70
79
}
71
80
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ impl OngoingCodegen {
106
106
}
107
107
}
108
108
109
- drop ( self . concurrency_limiter ) ;
109
+ self . concurrency_limiter . finished ( ) ;
110
110
111
111
(
112
112
CodegenResults {
You can’t perform that action at this time.
0 commit comments