EDU.oswego.cs.dl.util.concurrent

Class WaitableShort

Implemented Interfaces:
Cloneable, Comparable, Executor

public class WaitableShort
extends SynchronizedShort

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

[ Introduction to this package. ]

Field Summary

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

value_

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

lock_

Constructor Summary

WaitableShort(short initialValue)
Make a new WaitableShort with the given initial value, and using its own internal lock.
WaitableShort(short initialValue, Object lock)
Make a new WaitableShort with the given initial value, and using the supplied lock.

Method Summary

short
add(short amount)
boolean
commit(short assumedValue, short newValue)
short
decrement()
short
divide(short factor)
short
increment()
short
multiply(short factor)
short
set(short newValue)
short
subtract(short amount)
void
whenEqual(short c, Runnable action)
Wait until value equals c, then run action if nonnull.
void
whenGreater(short c, Runnable action)
wait until value greater than c, then run action if nonnull.
void
whenGreaterEqual(short c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
void
whenLess(short c, Runnable action)
wait until value less than c, then run action if nonnull.
void
whenLessEqual(short c, Runnable action)
wait until value less than or equal to c, then run action if nonnull.
void
whenNotEqual(short 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.SynchronizedShort

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

WaitableShort

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


WaitableShort

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

Method Details

add

public short add(short amount)
Overrides:
add in interface SynchronizedShort


commit

public boolean commit(short assumedValue,
                      short newValue)
Overrides:
commit in interface SynchronizedShort


decrement

public short decrement()
Overrides:
decrement in interface SynchronizedShort


divide

public short divide(short factor)
Overrides:
divide in interface SynchronizedShort


increment

public short increment()
Overrides:
increment in interface SynchronizedShort


multiply

public short multiply(short factor)
Overrides:
multiply in interface SynchronizedShort


set

public short set(short newValue)
Overrides:
set in interface SynchronizedShort


subtract

public short subtract(short amount)
Overrides:
subtract in interface SynchronizedShort


whenEqual

public void whenEqual(short 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(short 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(short 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(short 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(short 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(short 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.