EDU.oswego.cs.dl.util.concurrent

Class WaitableLong

public class WaitableLong extends SynchronizedLong

A class useful for offloading waiting and signalling operations on single long variables.

[ Introduction to this package. ]

Constructor Summary
WaitableLong(long initialValue)
Make a new WaitableLong with the given initial value, and using its own internal lock.
WaitableLong(long initialValue, Object lock)
Make a new WaitableLong with the given initial value, and using the supplied lock.
Method Summary
longadd(long amount)
longand(long b)
Set value to value & b.
booleancommit(long assumedValue, long newValue)
longcomplement()
Set the value to its complement
longdecrement()
longdivide(long factor)
longincrement()
longmultiply(long factor)
longor(long b)
Set value to value | b.
longset(long newValue)
longsubtract(long amount)
voidwhenEqual(long c, Runnable action)
Wait until value equals c, then run action if nonnull.
voidwhenGreater(long c, Runnable action)
wait until value greater than c, then run action if nonnull.
voidwhenGreaterEqual(long c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
voidwhenLess(long c, Runnable action)
wait until value less than c, then run action if nonnull.
voidwhenLessEqual(long c, Runnable action)
wait until value less than or equal to c, then run action if nonnull.
voidwhenNotEqual(long c, Runnable action)
wait until value not equal to c, then run action if nonnull.
longxor(long b)
Set value to value ^ b.

Constructor Detail

WaitableLong

public WaitableLong(long initialValue)
Make a new WaitableLong with the given initial value, and using its own internal lock.

WaitableLong

public WaitableLong(long initialValue, Object lock)
Make a new WaitableLong with the given initial value, and using the supplied lock.

Method Detail

add

public long add(long amount)

and

public long and(long b)
Set value to value & b.

Returns: the new value

commit

public boolean commit(long assumedValue, long newValue)

complement

public long complement()
Set the value to its complement

Returns: the new value

decrement

public long decrement()

divide

public long divide(long factor)

increment

public long increment()

multiply

public long multiply(long factor)

or

public long or(long b)
Set value to value | b.

Returns: the new value

set

public long set(long newValue)

subtract

public long subtract(long amount)

whenEqual

public void whenEqual(long c, Runnable action)
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.

whenGreater

public void whenGreater(long c, Runnable action)
wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.

whenGreaterEqual

public void whenGreaterEqual(long c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.

whenLess

public void whenLess(long c, Runnable action)
wait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.

whenLessEqual

public void whenLessEqual(long c, Runnable action)
wait until value less than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.

whenNotEqual

public void whenNotEqual(long c, Runnable action)
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.

xor

public long xor(long b)
Set value to value ^ b.

Returns: the new value