Class WaitableRef
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
EDU.oswego.cs.dl.util.concurrent.SynchronizedRef
EDU.oswego.cs.dl.util.concurrent.WaitableRef
- All Implemented Interfaces:
Executor
A class useful for offloading synch for Object reference instance variables.
-
Field Summary
Fields inherited from class SynchronizedRef
value_Fields inherited from class SynchronizedVariable
lock_ -
Constructor Summary
ConstructorsConstructorDescriptionWaitableRef(Object initialValue) Create a WaitableRef initially holding the given reference and using its own internal lock.WaitableRef(Object initialValue, Object lock) Make a new WaitableRef with the given initial value, and using the supplied lock. -
Method Summary
Modifier and TypeMethodDescriptionbooleanSet value to newValue only if it is currently assumedValue.Set to newValue.voidWait until value equals c, then run action if nonnull.voidwhenNotEqual(Object c, Runnable action) wait until value not equal to c, then run action if nonnull.voidwhenNotNull(Runnable action) wait until value is nonnull, then run action if nonnull.voidWait until value is null, then run action if nonnull.Methods inherited from class SynchronizedRef
get, swapMethods inherited from class SynchronizedVariable
execute, getLock
-
Constructor Details
-
WaitableRef
Create a WaitableRef initially holding the given reference and using its own internal lock. -
WaitableRef
-
-
Method Details
-
set
Description copied from class:SynchronizedRefSet to newValue.- Overrides:
setin classSynchronizedRef- Returns:
- the old value
-
commit
Description copied from class:SynchronizedRefSet value to newValue only if it is currently assumedValue.- Overrides:
commitin classSynchronizedRef- Returns:
- true if successful
-
whenNull
Wait until value is null, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenNotNull
wait until value is nonnull, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenEqual
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenNotEqual
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-