java.lang.Object
org.ematgine.utils.concurrent.SynchronizedVariable
org.ematgine.utils.concurrent.SynchronizedRef
org.ematgine.utils.concurrent.WaitableRef
- All Implemented Interfaces:
- Executor
- public class WaitableRef
- extends SynchronizedRef
A class useful for offloading synch for Object reference instance variables.
[ Introduction to this package. ]
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
WaitableRef
public WaitableRef(java.lang.Object initialValue)
- Create a WaitableRef initially holding the given reference
and using its own internal lock.
WaitableRef
public WaitableRef(java.lang.Object initialValue,
java.lang.Object lock)
- Make a new WaitableRef with the given initial value,
and using the supplied lock.
set
public java.lang.Object set(java.lang.Object newValue)
- Description copied from class:
SynchronizedRef
- Set to newValue.
- Overrides:
set in class SynchronizedRef
commit
public boolean commit(java.lang.Object assumedValue,
java.lang.Object newValue)
- Description copied from class:
SynchronizedRef
- Set value to newValue only if it is currently assumedValue.
- Overrides:
commit in class SynchronizedRef
whenNull
public void whenNull(java.lang.Runnable action)
throws java.lang.InterruptedException
- Wait until value is null, then run action if nonnull.
The action is run with the synchronization lock held.
whenNotNull
public void whenNotNull(java.lang.Runnable action)
throws java.lang.InterruptedException
- wait until value is nonnull, then run action if nonnull.
The action is run with the synchronization lock held.
whenEqual
public void whenEqual(java.lang.Object c,
java.lang.Runnable action)
throws java.lang.InterruptedException
- Wait until value equals c, then run action if nonnull.
The action is run with the synchronization lock held.
whenNotEqual
public void whenNotEqual(java.lang.Object c,
java.lang.Runnable action)
throws java.lang.InterruptedException
- wait until value not equal to c, then run action if nonnull.
The action is run with the synchronization lock held.