Github user franz1981 commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/1515#discussion_r137543702
--- Diff:
artemis-commons/src/main/java/org/apache/activemq/artemis/utils/critical/CriticalMeasure.java
---
@@ -17,36 +17,48 @@
package org.apache.activemq.artemis.utils.critical;
-import org.jboss.logging.Logger;
+import java.util.concurrent.atomic.AtomicLongFieldUpdater;
public 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;
--- End diff --
In that PR are fixed other parts that rely on the wrong mechanics of
nanoTime, while on this one it is taken in account here:
https://github.com/apache/activemq-artemis/pull/1515/files/a2189e0f6b74a40c1975fe2c0e15605d87b1c55e#diff-8a85ed9c24cc23c3b4230cae837e4797R34
With nanoTime there is no MIN_VALUE (absolute I mean) sadly: that's the
point of that PR.
ATM I don't have much time to explain it better, so please check the
javadoc I've linked there...
---