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)
boolean
commit(byte assumedValue, byte newValue)
byte
decrement()
byte
divide(byte factor)
byte
increment()
byte
multiply(byte factor)
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.

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


commit

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


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


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.