|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||
java.lang.Objectcom.yost.util.AtomicReferenceWithWait<T>
public class AtomicReferenceWithWait<T>
An object reference that can be updated atomically, and which allows
clients to wait for the value to change to suit their needs.
Unlike AtomicReference,
weakCompareAndSet
methodjava.util.concurrent.atomic package specification.
| Constructor Summary | |
|---|---|
AtomicReferenceWithWait()
Create a new AtomicReferenceWithWait with null initial value. |
|
AtomicReferenceWithWait(T initialValue)
Create a new AtomicReferenceWithWait with the given initial value. |
|
| Method Summary | |
|---|---|
boolean |
compareEqualsAndSet(T expect,
T update)
Atomically set the value to the given updated value if the current value equals the expected value. |
boolean |
compareIsAndSet(T expect,
T update)
Atomically set the value to the given updated value if the current value == the expected value. |
boolean |
compareIsNotAndSet(T expect,
T update)
Atomically set the value to the given updated value if the current value != the expected value. |
boolean |
compareNotEqualsAndSet(T expect,
T update)
Atomically set the value to the given updated value if the current value !equals the expected value. |
T |
get()
Get the current value. |
T |
getAndSet(T newValue)
Set to the given value and return the old value. |
Object |
getLockObject()
Get the monitor lock object. |
void |
set(T newValue)
Set to the given value. |
void |
setLockObject(Object newValue)
Set the monitor lock object. |
String |
toString()
Returns the String representation of the current value. |
T |
waitUntilValueEquals(T valueWanted)
Wait until value equals the desired value,
then return the current value. |
T |
waitUntilValueEqualsThenSet(T valueWanted,
T newValue)
Wait until value equals the desired object,
then set to newValue and return the old value. |
boolean |
waitUntilValueIs(T objectReferenceWanted)
Wait until value == the desired object,
then return true if no waiting was necessary. |
T |
waitUntilValueIsNot(T objectReferenceNotWanted)
Wait until value != the desired object,
then return the current value. |
T |
waitUntilValueIsNotThenSet(T objectReferenceWanted,
T newValue)
Wait until value != the desired object,
then set to newValue and return the old value. |
boolean |
waitUntilValueIsThenSet(T objectReferenceWanted,
T newValue)
Wait until value == the desired object,
then set to newValue
and return true if no waiting was necessary. |
T |
waitUntilValueNotEquals(T valueNotWanted)
Wait until value !equals the desired value,
then return the current value. |
T |
waitUntilValueNotEqualsThenSet(T valueWanted,
T newValue)
Wait until value not equals the desired object,
then set to newValue and return the old value. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
|---|
public AtomicReferenceWithWait(T initialValue)
AtomicReferenceWithWait with the given initial value.
initialValue - the initial valuepublic AtomicReferenceWithWait()
AtomicReferenceWithWait with null initial value.
| Method Detail |
|---|
public T get()
public void set(T newValue)
newValue - the new value
public final boolean compareIsAndSet(T expect,
T update)
== the expected value.
expect - the expected valueupdate - the new value
public final boolean compareEqualsAndSet(T expect,
T update)
equals the expected value.
expect - the expected valueupdate - the new value
public final boolean compareIsNotAndSet(T expect,
T update)
!= the expected value.
expect - the expected valueupdate - the new value
public final boolean compareNotEqualsAndSet(T expect,
T update)
!equals the expected value.
expect - the expected valueupdate - the new value
public final T getAndSet(T newValue)
newValue - the new value
public final boolean waitUntilValueIs(T objectReferenceWanted)
throws InterruptedException
== the desired object,
then return true if no waiting was necessary.
objectReferenceWanted - the desired object
InterruptedException
public final T waitUntilValueEquals(T valueWanted)
throws InterruptedException
equals the desired value,
then return the current value.
valueWanted - the current value
InterruptedException
public final T waitUntilValueIsNot(T objectReferenceNotWanted)
throws InterruptedException
!= the desired object,
then return the current value.
objectReferenceNotWanted - the undesired object
InterruptedException
public T waitUntilValueNotEquals(T valueNotWanted)
throws InterruptedException
!equals the desired value,
then return the current value.
valueNotWanted - the undesired value
InterruptedException
public final boolean waitUntilValueIsThenSet(T objectReferenceWanted,
T newValue)
throws InterruptedException
== the desired object,
then set to newValue
and return true if no waiting was necessary.
objectReferenceWanted - the desired objectnewValue - the new value
InterruptedException
public final T waitUntilValueEqualsThenSet(T valueWanted,
T newValue)
throws InterruptedException
equals the desired object,
then set to newValue and return the old value.
valueWanted - the desired objectnewValue - the new value
InterruptedException
public final T waitUntilValueIsNotThenSet(T objectReferenceWanted,
T newValue)
throws InterruptedException
!= the desired object,
then set to newValue and return the old value.
objectReferenceWanted - the desired objectnewValue - the new value
InterruptedException
public final T waitUntilValueNotEqualsThenSet(T valueWanted,
T newValue)
throws InterruptedException
equals the desired object,
then set to newValue and return the old value.
valueWanted - the desired objectnewValue - the new value
InterruptedExceptionpublic Object getLockObject()
public void setLockObject(Object newValue)
newValue - the new monitor lock objectpublic String toString()
toString in class Object
|
||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||