/** getAndSet returns previous value and sets to given value */ public void testGetAndSet() { double prev = Math.E; AtomicDouble at = new AtomicDouble(prev); for (double x : VALUES) { assertBitEquals(prev, at.getAndSet(x)); prev = x; } }
/** * <p> * Reset this {@link Counter} to its default value per * {@link Counter.Builder#defaultValue(Double)}. * </p> */ @Override public void reset() { value.getAndSet(defaultValue); } }
public boolean update(double d, long currentUserTimeClock) { value.getAndSet(d); this.latestUserTimeClock = currentUserTimeClock; return true; } }
/** * <p> * Set this {@link io.prometheus.client.metrics.Gauge.Child} to an arbitrary * value. * </p> */ public void set(final double v) { value.getAndSet(v); }
/** * <p> * Reset this {@link Gauge} to its default value per * {@link Gauge.Builder#defaultValue(Double)}. * </p> */ @Override public void reset() { value.getAndSet(defaultValue); } }
/** * <p> * Set this {@link io.prometheus.client.metrics.Counter.Child} to {@code v}. * </p> */ public void set(final double v) { value.getAndSet(v); }
public boolean update(double d, long currentUserTimeClock) { value.getAndSet(d); this.latestUserTimeClock = currentUserTimeClock; return true; } }
public double getAndResetConsumed() { return consumed.getAndSet(0.0); } }
private void tick(long time) { long oldOffset = tickOffset.get(); long newOffset = time / tick; long offsetDiff = newOffset - oldOffset; if (offsetDiff > 0L && tickOffset.compareAndSet(oldOffset, newOffset)) { double oldAverage = total.getAndSet(0.0) / tick; for (long i = 0L, size = offsetDiff - 1L; i < size; ++ i) { currentAverage += alpha * (0L - currentAverage); averages.add(currentAverage * 1e9); } currentAverage += alpha * (oldAverage - currentAverage); averages.add(currentAverage * 1e9); } }
public boolean update(double d, long currentUserTimeClock) { Boolean readyToFlushed = checkIfNeedFlush(currentUserTimeClock); if (!readyToFlushed) { if (currentUserTimeClock < latestUserTimeClock) { LOG.warn("Something must be wrong, event should come in order of userTimeClock"); } value.addAndGet(d); } else { flush(latestUserTimeClock); value.getAndSet(1); latestUserTimeClock = currentUserTimeClock; } return readyToFlushed; } }
public boolean update(double d, long currentUserTimeClock) { Boolean readyToFlushed = checkIfNeedFlush(currentUserTimeClock); if (!readyToFlushed) { if (currentUserTimeClock < latestUserTimeClock) { LOG.warn("Something must be wrong, event should come in order of userTimeClock"); } value.addAndGet(d); } else { flush(latestUserTimeClock); value.getAndSet(1); latestUserTimeClock = currentUserTimeClock; } return readyToFlushed; } }
/** * getAndSet returns previous value and sets to given value */ public void testGetAndSet() { double prev = Math.E; AtomicDouble at = new AtomicDouble(prev); for (double x : VALUES) { assertBitEquals(prev, at.getAndSet(x)); prev = x; } }