private void cleanupTemporaryGauges()

in src/main/java/org/apache/sling/commons/scheduler/impl/GaugesSupport.java [178:198]


    private void cleanupTemporaryGauges() {
        logger.debug("cleanupTemporaryGauges: checking for unused temporary gauges.");
        final long start = System.currentTimeMillis();
        final Map<String, TemporaryGauge> localTemporaryGauges;
        synchronized (temporaryGauges) {
            localTemporaryGauges = new HashMap<>(temporaryGauges);
        }
        final Iterator<TemporaryGauge> it = localTemporaryGauges.values().iterator();
        while (it.hasNext()) {
            TemporaryGauge gauge = it.next();
            // calling getValue will trigger the unregistration if applicable
            gauge.getValue();
        }
        final int endCount;
        synchronized (temporaryGauges) {
            endCount = temporaryGauges.size();
        }
        final long diff = System.currentTimeMillis() - start;
        logger.debug("cleanupTemporaryGauges: done. (temporary gauges at start : " + localTemporaryGauges.size()
                + ", at end : " + endCount + ", cleanup took : " + diff + "ms)");
    }