A class useful for offloading waiting and signalling operations
on single long variables.
Method from EDU.oswego.cs.dl.util.concurrent.WaitableLong Detail: |
public long add(long amount) {
synchronized (lock_) {
lock_.notifyAll();
return super.add(amount);
}
}
|
public long and(long b) {
synchronized (lock_) {
value_ = value_ & b;
lock_.notifyAll();
return value_;
}
}
|
public boolean commit(long assumedValue,
long newValue) {
synchronized (lock_) {
boolean success = super.commit(assumedValue, newValue);
if (success) lock_.notifyAll();
return success;
}
}
|
public long complement() {
synchronized (lock_) {
value_ = ~value_;
lock_.notifyAll();
return value_;
}
}
Set the value to its complement |
public long decrement() {
synchronized (lock_) {
lock_.notifyAll();
return super.decrement();
}
}
|
public long divide(long factor) {
synchronized (lock_) {
lock_.notifyAll();
return super.divide(factor);
}
}
|
public long increment() {
synchronized (lock_) {
lock_.notifyAll();
return super.increment();
}
}
|
public long multiply(long factor) {
synchronized (lock_) {
lock_.notifyAll();
return super.multiply(factor);
}
}
|
public long or(long b) {
synchronized (lock_) {
value_ = value_ | b;
lock_.notifyAll();
return value_;
}
}
|
public long set(long newValue) {
synchronized (lock_) {
lock_.notifyAll();
return super.set(newValue);
}
}
|
public long subtract(long amount) {
synchronized (lock_) {
lock_.notifyAll();
return super.subtract(amount);
}
}
|
public void whenEqual(long 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 whenGreater(long c,
Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!(value_ > c)) lock_.wait();
if (action != null) action.run();
}
}
wait until value greater than c, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenGreaterEqual(long c,
Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!(value_ >= c)) lock_.wait();
if (action != null) action.run();
}
}
wait until value greater than or equal to c, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenLess(long c,
Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!(value_ < c)) lock_.wait();
if (action != null) action.run();
}
}
wait until value less than c, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenLessEqual(long c,
Runnable action) throws InterruptedException {
synchronized (lock_) {
while (!(value_ < = c)) lock_.wait();
if (action != null) action.run();
}
}
wait until value less than or equal to c, then run action if nonnull.
The action is run with the synchronization lock held.
* |
public void whenNotEqual(long 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 long xor(long b) {
synchronized (lock_) {
value_ = value_ ^ b;
lock_.notifyAll();
return value_;
}
}
|