Guava AtomicDouble - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Guava AtomicDouble class.

This code example shows how to use the following methods:
     * Create a new instance with the specified configuration. 
     * 
     * @param config configuration for this gauge 
     */ 
    public DoubleGauge(MonitorConfig config) {
        super(config, new AtomicDouble(0.0));
        number = (AtomicDouble) getBackingNumber();
    } 
 
    /** 
     * Set the current value. 
     */ 
    public void set(Double n) {
        number.set(n);
    } 
 
    /** 
     * Returns a reference to the {@link com.google.common.util.concurrent.AtomicDouble}. 
     */ 
    public AtomicDouble getNumber() {
6
CodeRank
This code example shows how to use the following methods:set
    public float getCurrentActivityProgress() { 
        return (float) currentProgress.get();
    } 
 
    public void setCurrentProgress(float currentProgress) {
        this.currentProgress.set(currentProgress);
    } 
 
    @Override 
    public synchronized String getErrorMessage() {
        return errorMessage;
    } 
 
    public synchronized void setErrorMessage(String errorMessage) {
        this.errorMessage = errorMessage;
        status = Status.FAILED; 
    } 
 
    public synchronized void setComplete() { 
        status = Status.COMPLETE; 
5
CodeRank
This code example shows how to use the following methods:get, set
        private final AtomicDouble average = new AtomicDouble();
 
        synchronized void add(long value)
        { 
            count++;
            double oldAverage = average.get();
            average.set(oldAverage + ((value - oldAverage) / count));
        } 
 
        double get() 
        { 
            return average.get();
        } 
    } 
} 
5
CodeRank
This code example shows how to use the following methods:
 
        averages = new TimeSeries((long) (keepDuration * 1e3), (long) (measureInterval * 1e3));
        tick = (long) (measureInterval * 1e9);
        alpha = 1 - Math.exp(-tick / (averageInterval * 1e9));
        tickOffset = new AtomicLong(System.nanoTime() / tick);
        total = new AtomicDouble();
    } 
 
    // Updates the average if it's past time to measure. 
    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);
4
CodeRank
This code example shows how to use the following methods:addAndGet
      validateStructure(root);
 
      postOrderTraversal(root, new Callback() {
        @Override 
        public boolean process(Node node) {
          sumOfWeights.addAndGet(node.weightedCount);
          actualNodeCount.incrementAndGet();
 
          if (node.weightedCount > ZERO_WEIGHT_THRESHOLD) {
            actualNonZeroNodeCount.incrementAndGet();
          } 
 
          return true; 
        } 
      }); 
    } 
 
    checkState(Math.abs(sumOfWeights.get() - weightedCount) < ZERO_WEIGHT_THRESHOLD,
               "Computed weight (%s) doesn't match summary (%s)", sumOfWeights.get(),
               weightedCount);
2
CodeRank
See Code Examples for Guava AtomicDouble Methods: