/*
Synchronizable: counter is "updated" with the input value
161210
final public void decrement(long val) {
        if (!enabled)
            return;

        lastSampleTime = System.currentTimeMillis();
        if (!sync) {
            count -= val;
        } else {
            synchronized (this) {
                count -= val;
            }
        }
    }
519533
public synchronized void synchronizeWith(UpdateSynchronizer newsync) {
    // LoggingUtil.warning("Synchronizing: " + sync + " " + newsync, new
    // Throwable());
    if(synchronizer == newsync) {
      LoggingUtil.warning("Double-synced to the same plot!", new Throwable());
      return;
    }
    if(synchronizer != null) {
      LoggingUtil.warning("Attempting to synchronize to more than one synchronizer.");
      return;
    }
    synchronizer = newsync;
    newsync.addUpdateRunner(this);
  }
161008
function (dt) {
        var i, len, x
        if (this.timeScale != 1.0) {
            dt *= this.timeScale
        }

        var entry
        for (i = 0, len = this.updatesNeg.length; i < len; i++) {
            entry = this.updatesNeg[i]
            if (entry && !entry.paused) {
                entry.target.update(dt)
            }
        }


        for (i = 0, len = this.updates0.length; i < len; i++) {
            entry = this.updates0[i]
            if (entry && !entry.paused) {
                entry.target.update(dt)
            }
        }

        for (i = 0, len = this.updatesPos.length; i < len; i++) {
            entry = this.updatesPos[i]
            if (entry && !entry.paused) {
                entry.target.update(dt)
            }
        }

        for (x in this.hashForMethods) {
            if (this.hashForMethods.hasOwnProperty(x)) {
                entry = this.hashForMethods[x]

                if (entry) {
                    for (i = 0, len = entry.timers.length; i < len; i++) {
                        var timer = entry.timers[i]
                        if (timer) {
                            timer.update(dt)
                        }
                    }
                }
            }
        }

    }
856397
protected void updatePatternSet(PatternSet value, String xmlTag, Counter counter, Element element)
   {
      boolean shouldExist = value != null;
      Element root = updateElement(counter, element, xmlTag, shouldExist);
      if (shouldExist)
      {
         Counter innerCount = new Counter(counter.getDepth() + 1);
         findAndReplaceSimpleLists(innerCount, root, value.getIncludes(), "includes", "include");
         findAndReplaceSimpleLists(innerCount, root, value.getExcludes(), "excludes", "exclude");
      }
   }
67786
function _counter() {
    var counter = this.single.counter;
    var toUpdate = {};
    toUpdate[counter.column] = this.client.raw(this.formatter.wrap(counter.column) + ' ' + (counter.symbol || '+') + ' ' + counter.amount);
    this.single.update = toUpdate;
    return this.update();
  }
239409
final public void add(long curTime, long val) {
        if (!enabled)
            return;

        lastSampleTime = curTime;
        if (!sync) {
            if (val > max)
                max = val;

            if (count > 0) {
                if (val < min)
                    min = val;
            } else
                min = val; //set min=val for the first time

            /*
             * if (val < min || min < 0)
             * min = val;
             */
            count++;
            total += val;
            sumOfSquares += val * val;
        } else {
            // synchronized ONLY the count updates
            synchronized (this) {
                count++;
                total += val;
            }

            if (val > max)
                max = val;

            if (count > 0) {
                if (val < min)
                    min = val;
            } else
                min = val; //set min=val for the first time

            sumOfSquares += val * val;
        }
    }
444050
public synchronized U update(int i, Function<U, U> updater) {
    U updated = updater.apply(this.get(i));
    set(i, updated);
    return updated;
  }
511173
@Override
	public void update() {
		synchronized (this) {
			long currentTime = System.currentTimeMillis();
			if (currentTime - lastUpdateTime > updateInterval) {
				lastUpdateTime = currentTime;
				fetchMetrics();
			}
		}
	}
267074
final public void decrementWithSyncFlag(long curTime, long val) {
        if (enabled) {
            lastSampleTime = updateIntegral(curTime);
            if (sync) {
                synchronized (this) {
                    current -= val;
                }
            } else {
                current -= val;
                // to eliminate negative numbers
                if (current < 0)
                    current = 0;
            }
            updateWaterMark();
        } else {
            current -= val;
        }
    }
694666
private void updateValue() {
        if (table != null) {
            int oldCount = this.count;
            this.count = table.getSelectedRowCount();
            maybeNotifyListeners(oldCount, count);
        }
    }
691472
function isCounterAfter(counter, currentStateCounter)
{
	const diff = counter - currentStateCounter

	// If the new options are "newer" than the current ones,
	// then they can override them.
	// (also accounts for counter overflow)
	return diff > 0 || (diff < 0 && Math.abs(diff) > MAX_SAFE_INTEGER / 2)
}
383597
protected void valueChanged()
	{
		String newValue = fViewer.getDocument().get();
		if (!newValue.equals(fOldValue))
		{
			fOldValue = newValue;

		}
		refreshValidState();
	}
414022
function (name, value, oldValue) {
                this.$InputElement.onbind.apply(this, arguments);
                if (name === "checked") {
                    this._domElt.checked = value;
                }
            }
1228134
@Override
    public void update(Number obj) {
        if (enable == false) {
            return;
        }

        if (intervalCheck.check()) {
            flush();
        }
        synchronized (this) {
            unflushed = updater.update(obj, unflushed);
        }
    }
175604
def _ensure_counter(self):
        """"""
        if not isinstance(self.sync_counter, self._SynchronizationManager):
            self.sync_counter = self._SynchronizationManager()
327944
public void updateIf (T value)
    {
        if (value == null || !value.equals(_value)) {
            update(value);
        }
    }
1355612
@Override
    protected void applyValueUpdate(final T value) throws NotAvailableException {

        if(value == null) {
            throw new NotAvailableException("Value");
        }

        synchronized (VALUE_LOCK) {
            this.value = value;
            this.valueFuture.complete(value);
            VALUE_LOCK.notifyAll();
        }
    }