Prev Class | Next Class | Frames | No Frames |
Summary: Nested | Field | Method | Constr | Detail: Nested | Field | Method | Constr |
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
EDU.oswego.cs.dl.util.concurrent.SynchronizedLong
EDU.oswego.cs.dl.util.concurrent.WaitableLong
public class WaitableLong
extends SynchronizedLong
Field Summary |
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedLong | |
value_ |
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable | |
lock_ |
Constructor Summary | |
| |
|
Method Summary | |
long |
|
long |
|
boolean |
|
long |
|
long |
|
long |
|
long |
|
long |
|
long |
|
long |
|
long |
|
void |
|
void |
|
void |
|
void |
|
void |
|
void |
|
long |
|
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedLong | |
add , and , commit , compareTo , compareTo , compareTo , complement , decrement , divide , equals , get , hashCode , increment , multiply , negate , or , set , subtract , swap , toString , xor |
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable | |
execute , getLock |
public WaitableLong(long initialValue)
Make a new WaitableLong with the given initial value, and using its own internal lock.
public WaitableLong(long initialValue, Object lock)
Make a new WaitableLong with the given initial value, and using the supplied lock.
public long add(long amount)
Add amount to value (i.e., set value += amount)
- Overrides:
- add in interface SynchronizedLong
- Returns:
- the new value
public long and(long b)
Set value to value & b.
- Overrides:
- and in interface SynchronizedLong
- Returns:
- the new value
public boolean commit(long assumedValue, long newValue)
Set value to newValue only if it is currently assumedValue.
- Overrides:
- commit in interface SynchronizedLong
- Returns:
- true if successful
public long complement()
Set the value to its complement
- Overrides:
- complement in interface SynchronizedLong
- Returns:
- the new value
public long decrement()
Decrement the value.
- Overrides:
- decrement in interface SynchronizedLong
- Returns:
- the new value
public long divide(long factor)
Divide value by factor (i.e., set value /= factor)
- Overrides:
- divide in interface SynchronizedLong
- Returns:
- the new value
public long increment()
Increment the value.
- Overrides:
- increment in interface SynchronizedLong
- Returns:
- the new value
public long multiply(long factor)
Multiply value by factor (i.e., set value *= factor)
- Overrides:
- multiply in interface SynchronizedLong
- Returns:
- the new value
public long or(long b)
Set value to value | b.
- Overrides:
- or in interface SynchronizedLong
- Returns:
- the new value
public long set(long newValue)
Set to newValue.
- Overrides:
- set in interface SynchronizedLong
- Returns:
- the old value
public long subtract(long amount)
Subtract amount from value (i.e., set value -= amount)
- Overrides:
- subtract in interface SynchronizedLong
- Returns:
- the new value
public void whenEqual(long c, Runnable action) throws InterruptedException
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
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
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
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
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
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)
Set value to value ^ b.
- Overrides:
- xor in interface SynchronizedLong
- Returns:
- the new value