jdk/src/java.base/share/classes/java/util/concurrent/atomic/AtomicLongArray.java
changeset 40733 8d1263354d62
parent 39725 9548f8d846e9
child 40734 48879ea67e2a
equal deleted inserted replaced
40732:2fd9cf42bb3c 40733:8d1263354d62
   198         return (long)AA.getAndAdd(array, i, delta);
   198         return (long)AA.getAndAdd(array, i, delta);
   199     }
   199     }
   200 
   200 
   201     /**
   201     /**
   202      * Atomically increments the value of the element at index {@code i},
   202      * Atomically increments the value of the element at index {@code i},
   203      * with memory effects as specified by {@link VarHandle#addAndGet}.
   203      * with memory effects as specified by {@link VarHandle#getAndAdd}.
   204      *
   204      *
   205      * <p>Equivalent to {@code addAndGet(i, 1)}.
   205      * <p>Equivalent to {@code addAndGet(i, 1)}.
   206      *
   206      *
   207      * @param i the index
   207      * @param i the index
   208      * @return the updated value
   208      * @return the updated value
   209      */
   209      */
   210     public final long incrementAndGet(int i) {
   210     public final long incrementAndGet(int i) {
   211         return (long)AA.addAndGet(array, i, 1L);
   211         return (long)AA.getAndAdd(array, i, 1L) + 1L;
   212     }
   212     }
   213 
   213 
   214     /**
   214     /**
   215      * Atomically decrements the value of the element at index {@code i},
   215      * Atomically decrements the value of the element at index {@code i},
   216      * with memory effects as specified by {@link VarHandle#addAndGet}.
   216      * with memory effects as specified by {@link VarHandle#getAndAdd}.
   217      *
   217      *
   218      * <p>Equivalent to {@code addAndGet(i, -1)}.
   218      * <p>Equivalent to {@code addAndGet(i, -1)}.
   219      *
   219      *
   220      * @param i the index
   220      * @param i the index
   221      * @return the updated value
   221      * @return the updated value
   222      */
   222      */
   223     public final long decrementAndGet(int i) {
   223     public final long decrementAndGet(int i) {
   224         return (long)AA.addAndGet(array, i, -1L);
   224         return (long)AA.getAndAdd(array, i, -1L) - 1L;
   225     }
   225     }
   226 
   226 
   227     /**
   227     /**
   228      * Atomically adds the given value to the element at index {@code i},
   228      * Atomically adds the given value to the element at index {@code i},
   229      * with memory effects as specified by {@link VarHandle#addAndGet}.
   229      * with memory effects as specified by {@link VarHandle#getAndAdd}.
   230      *
   230      *
   231      * @param i the index
   231      * @param i the index
   232      * @param delta the value to add
   232      * @param delta the value to add
   233      * @return the updated value
   233      * @return the updated value
   234      */
   234      */
   235     public long addAndGet(int i, long delta) {
   235     public long addAndGet(int i, long delta) {
   236         return (long)AA.addAndGet(array, i, delta);
   236         return (long)AA.getAndAdd(array, i, delta) + delta;
   237     }
   237     }
   238 
   238 
   239     /**
   239     /**
   240      * Atomically updates the element at index {@code i} with the results
   240      * Atomically updates the element at index {@code i} with the results
   241      * of applying the given function, returning the previous value. The
   241      * of applying the given function, returning the previous value. The