EDU.oswego.cs.dl.util.concurrent

Class WaitableByte

public class WaitableByte extends SynchronizedByte

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

[ Introduction to this package. ]

Constructor Summary
WaitableByte(byte initialValue)
Make a new WaitableByte with the given initial value, and using its own internal lock.
WaitableByte(byte initialValue, Object lock)
Make a new WaitableByte with the given initial value, and using the supplied lock.
Method Summary
byteadd(byte amount)
byteand(byte b)
Set value to value & b.
booleancommit(byte assumedValue, byte newValue)
bytecomplement()
Set the value to its complement
bytedecrement()
bytedivide(byte factor)
byteincrement()
bytemultiply(byte factor)
byteor(byte b)
Set value to value | b.
byteset(byte newValue)
bytesubtract(byte amount)
voidwhenEqual(byte c, Runnable action)
Wait until value equals c, then run action if nonnull.
voidwhenGreater(byte c, Runnable action)
wait until value greater than c, then run action if nonnull.
voidwhenGreaterEqual(byte c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
voidwhenLess(byte c, Runnable action)
wait until value less than c, then run action if nonnull.
voidwhenLessEqual(byte c, Runnable action)
wait until value less than or equal to c, then run action if nonnull.
voidwhenNotEqual(byte c, Runnable action)
wait until value not equal to c, then run action if nonnull.
bytexor(byte b)
Set value to value ^ b.

Constructor Detail

WaitableByte

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

WaitableByte

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

Method Detail

add

public byte add(byte amount)

and

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

Returns: the new value

commit

public boolean commit(byte assumedValue, byte newValue)

complement

public byte complement()
Set the value to its complement

Returns: the new value

decrement

public byte decrement()

divide

public byte divide(byte factor)

increment

public byte increment()

multiply

public byte multiply(byte factor)

or

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

Returns: the new value

set

public byte set(byte newValue)

subtract

public byte subtract(byte amount)

whenEqual

public void whenEqual(byte 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(byte 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(byte 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(byte 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(byte 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(byte 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 byte xor(byte b)
Set value to value ^ b.

Returns: the new value