com.atlassian.util.concurrent.atomic
Class AtomicReferenceUpdater<T>

java.lang.Object
  extended by com.atlassian.util.concurrent.atomic.AtomicReferenceUpdater<T>
Type Parameters:
T - the type of the reference.
All Implemented Interfaces:
com.google.common.base.Function<T,T>

public abstract class AtomicReferenceUpdater<T>
extends java.lang.Object
implements com.google.common.base.Function<T,T>

Experimental. Please note this class is experimental and may be removed in later versions unless you really, really like it. If you do, mail me, [email protected]

Implements the logic for updating an AtomicReference correctly, using the current value, computing the update and then setting it if it hasn't changed in the meantime.

This is an abstract class that has a factory template method to implement the new value creation.

Since:
0.0.12

Constructor Summary
AtomicReferenceUpdater(java.util.concurrent.atomic.AtomicReference<T> reference)
           
 
Method Summary
 T update()
          Do the actual update.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.google.common.base.Function
apply, equals
 

Constructor Detail

AtomicReferenceUpdater

public AtomicReferenceUpdater(java.util.concurrent.atomic.AtomicReference<T> reference)
Method Detail

update

public final T update()
Do the actual update. Calls the factory method with the old value to do the update logic, then sets the value to that if it hasn't changed in the meantime.

Returns:
the new updated value.


Copyright © 2011 Atlassian. All Rights Reserved.