jdk/src/share/classes/java/util/concurrent/atomic/AtomicReference.java
changeset 16011 890a7ed97f6c
parent 15267 c884f548a25f
child 18576 7a5c231327af
equal deleted inserted replaced
16010:2727163b5df5 16011:890a7ed97f6c
   155      */
   155      */
   156     public final V getAndUpdate(UnaryOperator<V> updateFunction) {
   156     public final V getAndUpdate(UnaryOperator<V> updateFunction) {
   157         V prev, next;
   157         V prev, next;
   158         do {
   158         do {
   159             prev = get();
   159             prev = get();
   160             next = updateFunction.operate(prev);
   160             next = updateFunction.apply(prev);
   161         } while (!compareAndSet(prev, next));
   161         } while (!compareAndSet(prev, next));
   162         return prev;
   162         return prev;
   163     }
   163     }
   164 
   164 
   165     /**
   165     /**
   174      */
   174      */
   175     public final V updateAndGet(UnaryOperator<V> updateFunction) {
   175     public final V updateAndGet(UnaryOperator<V> updateFunction) {
   176         V prev, next;
   176         V prev, next;
   177         do {
   177         do {
   178             prev = get();
   178             prev = get();
   179             next = updateFunction.operate(prev);
   179             next = updateFunction.apply(prev);
   180         } while (!compareAndSet(prev, next));
   180         } while (!compareAndSet(prev, next));
   181         return next;
   181         return next;
   182     }
   182     }
   183 
   183 
   184     /**
   184     /**
   198     public final V getAndAccumulate(V x,
   198     public final V getAndAccumulate(V x,
   199                                     BinaryOperator<V> accumulatorFunction) {
   199                                     BinaryOperator<V> accumulatorFunction) {
   200         V prev, next;
   200         V prev, next;
   201         do {
   201         do {
   202             prev = get();
   202             prev = get();
   203             next = accumulatorFunction.operate(prev, x);
   203             next = accumulatorFunction.apply(prev, x);
   204         } while (!compareAndSet(prev, next));
   204         } while (!compareAndSet(prev, next));
   205         return prev;
   205         return prev;
   206     }
   206     }
   207 
   207 
   208     /**
   208     /**
   222     public final V accumulateAndGet(V x,
   222     public final V accumulateAndGet(V x,
   223                                     BinaryOperator<V> accumulatorFunction) {
   223                                     BinaryOperator<V> accumulatorFunction) {
   224         V prev, next;
   224         V prev, next;
   225         do {
   225         do {
   226             prev = get();
   226             prev = get();
   227             next = accumulatorFunction.operate(prev, x);
   227             next = accumulatorFunction.apply(prev, x);
   228         } while (!compareAndSet(prev, next));
   228         } while (!compareAndSet(prev, next));
   229         return next;
   229         return next;
   230     }
   230     }
   231 
   231 
   232     /**
   232     /**