activemq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From franz1981 <>
Subject [GitHub] activemq-artemis pull request #1515: ARTEMIS-1393 CriticalAnalyzer timeout u...
Date Thu, 07 Sep 2017 05:40:24 GMT
Github user franz1981 commented on a diff in the pull request:
    --- Diff: artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/
    @@ -17,28 +17,39 @@
     package org.apache.activemq.artemis.utils.critical;
    -import org.jboss.logging.Logger;
    +import java.util.concurrent.TimeUnit;
    +import java.util.concurrent.atomic.AtomicLongFieldUpdater;
    -public class CriticalMeasure {
    +final class CriticalMeasure {
    -   private static final Logger logger = Logger.getLogger(CriticalMeasure.class);
    +   //uses updaters to avoid creates many AtomicLong instances
    +   private static final AtomicLongFieldUpdater<CriticalMeasure> TIME_ENTER_UPDATER
= AtomicLongFieldUpdater.newUpdater(CriticalMeasure.class, "timeEnter");
    +   private static final AtomicLongFieldUpdater<CriticalMeasure> TIME_LEFT_UPDATER
= AtomicLongFieldUpdater.newUpdater(CriticalMeasure.class, "timeLeft");
    -   private volatile long timeEnter;
    -   private volatile long timeLeft;
    +   //System::nanoTime can't reach this value so it's the best candidate to have a NULL
    +   private static final long NIL = Long.MAX_VALUE;
    --- End diff --
    Can't be done sadly.
    It is mostly OS dependent and on Linux nanoTime can start with Long.MIN too (or near to
it). So having it with a safe "null" as I've done is the only way to let it work across OSes.


View raw message