EDU.oswego.cs.dl.util.concurrent

Class WaitableByte

Implemented Interfaces:
Cloneable, Comparable, Executor

public class WaitableByte
extends SynchronizedByte

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

[ Introduction to this package. ]

Field Summary

Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedByte

value_

Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable

lock_

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

byte
add(byte amount)
byte
and(byte b)
Set value to value & b.
boolean
commit(byte assumedValue, byte newValue)
byte
complement()
Set the value to its complement
byte
decrement()
byte
divide(byte factor)
byte
increment()
byte
multiply(byte factor)
byte
or(byte b)
Set value to value | b.
byte
set(byte newValue)
byte
subtract(byte amount)
void
whenEqual(byte c, Runnable action)
Wait until value equals c, then run action if nonnull.
void
whenGreater(byte c, Runnable action)
wait until value greater than c, then run action if nonnull.
void
whenGreaterEqual(byte c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
void
whenLess(byte c, Runnable action)
wait until value less than c, then run action if nonnull.
void
whenLessEqual(byte c, Runnable action)
wait until value less than or equal to c, then run action if nonnull.
void
whenNotEqual(byte c, Runnable action)
wait until value not equal to c, then run action if nonnull.
byte
xor(byte b)
Set value to value ^ b.

Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedByte

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

Constructor Details

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 Details

add

public byte add(byte amount)
Overrides:
add in interface SynchronizedByte

and

public byte and(byte b)
Set value to value & b.
Overrides:
and in interface SynchronizedByte
Returns:
the new value

commit

public boolean commit(byte assumedValue,
                      byte newValue)
Overrides:
commit in interface SynchronizedByte

complement

public byte complement()
Set the value to its complement
Overrides:
complement in interface SynchronizedByte
Returns:
the new value

decrement

public byte decrement()
Overrides:
decrement in interface SynchronizedByte

divide

public byte divide(byte factor)
Overrides:
divide in interface SynchronizedByte

increment

public byte increment()
Overrides:
increment in interface SynchronizedByte

multiply

public byte multiply(byte factor)
Overrides:
multiply in interface SynchronizedByte

or

public byte or(byte b)
Set value to value | b.
Overrides:
or in interface SynchronizedByte
Returns:
the new value

set

public byte set(byte newValue)
Overrides:
set in interface SynchronizedByte

subtract

public byte subtract(byte amount)
Overrides:
subtract in interface SynchronizedByte

whenEqual

public void whenEqual(byte c,
                      Runnable action)
            throws InterruptedException
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)
            throws InterruptedException
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)
            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.

whenLess

public void whenLess(byte 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.

whenLessEqual

public void whenLessEqual(byte 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.

whenNotEqual

public void whenNotEqual(byte 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.

xor

public byte xor(byte b)
Set value to value ^ b.
Overrides:
xor in interface SynchronizedByte
Returns:
the new value