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)
short
and(short b)
Set value to value & b.
boolean
commit(short assumedValue, short newValue)
short
complement()
Set the value to its complement
short
decrement()
short
divide(short factor)
short
increment()
short
multiply(short factor)
short
or(short b)
Set value to value | b.
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.
short
xor(short b)
Set value to value ^ b.

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

and

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

commit

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

complement

public short complement()
Set the value to its complement
Overrides:
complement in interface SynchronizedShort
Returns:
the new value

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

or

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

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.

xor

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