File tree 1 file changed +5
-1
lines changed
1 file changed +5
-1
lines changed Original file line number Diff line number Diff line change @@ -155,14 +155,18 @@ private MasterCleaner() {
155
155
@ Override
156
156
public void run () {
157
157
long now ;
158
+ long lastMasterRun = 0 ;
158
159
while ((now = System .currentTimeMillis ()) < lastNonEmpty + MASTER_MAX_LINGER_MS || !deleteIfEmpty ()) {
159
160
if (!cleanerImpls .isEmpty ()) { lastNonEmpty = now ; }
160
161
try {
161
162
Reference <?> ref = impl .referenceQueue .remove (MASTER_CLEANUP_INTERVAL_MS );
162
163
if (ref instanceof CleanerRef ) {
163
164
((CleanerRef ) ref ).clean ();
164
- } else {
165
+ }
166
+ // "now" is not really *now* at this point, but off by no more than MASTER_CLEANUP_INTERVAL_MS
167
+ if (lastMasterRun + MASTER_CLEANUP_INTERVAL_MS <= now ) {
165
168
masterCleanup ();
169
+ lastMasterRun = now ;
166
170
}
167
171
} catch (InterruptedException ex ) {
168
172
// Can be raised on shutdown. If anyone else messes with
You can’t perform that action at this time.
0 commit comments