A class useful for offloading synch for Object reference instance variables.
Method from EDU.oswego.cs.dl.util.concurrent.WaitableRef Detail: |
public boolean commit(Object assumedValue,
Object newValue) {
synchronized (lock_) {
boolean success = super.commit(assumedValue, newValue);
if (success) lock_.notifyAll();
return success;
}
}
|
public Object set(Object newValue) {
synchronized (lock_) {
lock_.notifyAll();
return super.set(newValue);
}
}
|
public void whenEqual(Object c,
Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!(value_ == c)) lock_.wait();
if (action != null) action.run();
}
}
Wait until value equals c, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenNotEqual(Object c,
Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!(value_ != c)) lock_.wait();
if (action != null) action.run();
}
}
wait until value not equal to c, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenNotNull(Runnable action) throws InterruptedException {
synchronized (lock_) {
while (value_ == null) lock_.wait();
if (action != null) action.run();
}
}
wait until value is nonnull, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenNull(Runnable action) throws InterruptedException {
synchronized (lock_) {
while (value_ != null) lock_.wait();
if (action != null) action.run();
}
}
Wait until value is null, then run action if nonnull.
The action is run with the synchronization lock held.
* |