A class useful for offloading synch for boolean instance variables.
Method from EDU.oswego.cs.dl.util.concurrent.WaitableBoolean Detail: |
public boolean and(boolean b) {
synchronized (lock_) {
lock_.notifyAll();
return super.and(b);
}
}
|
public boolean commit(boolean assumedValue,
boolean newValue) {
synchronized (lock_) {
boolean success = super.commit(assumedValue, newValue);
if (success) lock_.notifyAll();
return success;
}
}
|
public boolean complement() {
synchronized (lock_) {
lock_.notifyAll();
return super.complement();
}
}
|
public boolean or(boolean b) {
synchronized (lock_) {
lock_.notifyAll();
return super.or(b);
}
}
|
public boolean set(boolean newValue) {
synchronized (lock_) {
lock_.notifyAll();
return super.set(newValue);
}
}
|
public void whenEqual(boolean 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 whenFalse(Runnable action) throws InterruptedException {
synchronized (lock_) {
while (value_) lock_.wait();
if (action != null) action.run();
}
}
Wait until value is false, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenNotEqual(boolean 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 whenTrue(Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!value_) lock_.wait();
if (action != null) action.run();
}
}
wait until value is true, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public boolean xor(boolean b) {
synchronized (lock_) {
lock_.notifyAll();
return super.xor(b);
}
}
|