private void rescaleIfNeeded() { var now = clock.getTick(); var next = _nextScaleTime.Get(); if (now >= next) { Rescale(now, next); } }
private bool shouldLoad() { for (;;) { long time = clock.getTick(); long currentReload = reloadAt.Get(); if (currentReload > time) { return(false); } if (reloadAt.CompareAndSet(currentReload, time + timeoutNS)) { return(true); } } }
private void tickIfNecessary() { long oldTick = _lastTick.Get(); long newTick = clock.getTick(); long age = newTick - oldTick; if (age > TICK_INTERVAL) { long newIntervalStartTick = newTick - age % TICK_INTERVAL; if (_lastTick.CompareAndSet(oldTick, newIntervalStartTick)) { long requiredTicks = age / TICK_INTERVAL; for (long i = 0; i < requiredTicks; i++) { _m1Rate.Tick(); _m5Rate.Tick(); _m15Rate.Tick(); } } } }