jdk/src/share/classes/java/util/concurrent/atomic/AtomicLongFieldUpdater.java
changeset 16011 890a7ed97f6c
parent 15267 c884f548a25f
child 16906 44dfee24cb71
equal deleted inserted replaced
16010:2727163b5df5 16011:890a7ed97f6c
   282      */
   282      */
   283     public final long getAndUpdate(T obj, LongUnaryOperator updateFunction) {
   283     public final long getAndUpdate(T obj, LongUnaryOperator updateFunction) {
   284         long prev, next;
   284         long prev, next;
   285         do {
   285         do {
   286             prev = get(obj);
   286             prev = get(obj);
   287             next = updateFunction.operateAsLong(prev);
   287             next = updateFunction.applyAsLong(prev);
   288         } while (!compareAndSet(obj, prev, next));
   288         } while (!compareAndSet(obj, prev, next));
   289         return prev;
   289         return prev;
   290     }
   290     }
   291 
   291 
   292     /**
   292     /**
   302      */
   302      */
   303     public final long updateAndGet(T obj, LongUnaryOperator updateFunction) {
   303     public final long updateAndGet(T obj, LongUnaryOperator updateFunction) {
   304         long prev, next;
   304         long prev, next;
   305         do {
   305         do {
   306             prev = get(obj);
   306             prev = get(obj);
   307             next = updateFunction.operateAsLong(prev);
   307             next = updateFunction.applyAsLong(prev);
   308         } while (!compareAndSet(obj, prev, next));
   308         } while (!compareAndSet(obj, prev, next));
   309         return next;
   309         return next;
   310     }
   310     }
   311 
   311 
   312     /**
   312     /**
   327     public final long getAndAccumulate(T obj, long x,
   327     public final long getAndAccumulate(T obj, long x,
   328                                        LongBinaryOperator accumulatorFunction) {
   328                                        LongBinaryOperator accumulatorFunction) {
   329         long prev, next;
   329         long prev, next;
   330         do {
   330         do {
   331             prev = get(obj);
   331             prev = get(obj);
   332             next = accumulatorFunction.operateAsLong(prev, x);
   332             next = accumulatorFunction.applyAsLong(prev, x);
   333         } while (!compareAndSet(obj, prev, next));
   333         } while (!compareAndSet(obj, prev, next));
   334         return prev;
   334         return prev;
   335     }
   335     }
   336 
   336 
   337     /**
   337     /**
   352     public final long accumulateAndGet(T obj, long x,
   352     public final long accumulateAndGet(T obj, long x,
   353                                        LongBinaryOperator accumulatorFunction) {
   353                                        LongBinaryOperator accumulatorFunction) {
   354         long prev, next;
   354         long prev, next;
   355         do {
   355         do {
   356             prev = get(obj);
   356             prev = get(obj);
   357             next = accumulatorFunction.operateAsLong(prev, x);
   357             next = accumulatorFunction.applyAsLong(prev, x);
   358         } while (!compareAndSet(obj, prev, next));
   358         } while (!compareAndSet(obj, prev, next));
   359         return next;
   359         return next;
   360     }
   360     }
   361 
   361 
   362     private static class CASUpdater<T> extends AtomicLongFieldUpdater<T> {
   362     private static class CASUpdater<T> extends AtomicLongFieldUpdater<T> {