Package EDU.oswego.cs.dl.util.concurrent
Class WaitableShort
- java.lang.Object
-
- EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
-
- EDU.oswego.cs.dl.util.concurrent.SynchronizedShort
-
- EDU.oswego.cs.dl.util.concurrent.WaitableShort
-
- All Implemented Interfaces:
Executor,Cloneable,Comparable
public class WaitableShort extends SynchronizedShort
A class useful for offloading waiting and signalling operations on single short variables.
-
-
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
Constructors Constructor Description 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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description shortadd(short amount)Add amount to value (i.e., set value += amount)shortand(short b)Set value to value & b.booleancommit(short assumedValue, short newValue)Set value to newValue only if it is currently assumedValue.shortcomplement()Set the value to its complementshortdecrement()Decrement the value.shortdivide(short factor)Divide value by factor (i.e., set value /= factor)shortincrement()Increment the value.shortmultiply(short factor)Multiply value by factor (i.e., set value *= factor)shortor(short b)Set value to value | b.shortset(short newValue)Set to newValue.shortsubtract(short amount)Subtract amount from value (i.e., set value -= amount)voidwhenEqual(short c, Runnable action)Wait until value equals c, then run action if nonnull.voidwhenGreater(short c, Runnable action)wait until value greater than c, then run action if nonnull.voidwhenGreaterEqual(short c, Runnable action)wait until value greater than or equal to c, then run action if nonnull.voidwhenLess(short c, Runnable action)wait until value less than c, then run action if nonnull.voidwhenLessEqual(short c, Runnable action)wait until value less than or equal to c, then run action if nonnull.voidwhenNotEqual(short c, Runnable action)wait until value not equal to c, then run action if nonnull.shortxor(short b)Set value to value ^ b.-
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedShort
compareTo, compareTo, compareTo, equals, get, hashCode, negate, swap, toString
-
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
execute, getLock
-
-
-
-
Constructor Detail
-
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 Detail
-
set
public short set(short newValue)
Description copied from class:SynchronizedShortSet to newValue.- Overrides:
setin classSynchronizedShort- Returns:
- the old value
-
commit
public boolean commit(short assumedValue, short newValue)Description copied from class:SynchronizedShortSet value to newValue only if it is currently assumedValue.- Overrides:
commitin classSynchronizedShort- Returns:
- true if successful
-
increment
public short increment()
Description copied from class:SynchronizedShortIncrement the value.- Overrides:
incrementin classSynchronizedShort- Returns:
- the new value
-
decrement
public short decrement()
Description copied from class:SynchronizedShortDecrement the value.- Overrides:
decrementin classSynchronizedShort- Returns:
- the new value
-
add
public short add(short amount)
Description copied from class:SynchronizedShortAdd amount to value (i.e., set value += amount)- Overrides:
addin classSynchronizedShort- Returns:
- the new value
-
subtract
public short subtract(short amount)
Description copied from class:SynchronizedShortSubtract amount from value (i.e., set value -= amount)- Overrides:
subtractin classSynchronizedShort- Returns:
- the new value
-
multiply
public short multiply(short factor)
Description copied from class:SynchronizedShortMultiply value by factor (i.e., set value *= factor)- Overrides:
multiplyin classSynchronizedShort- Returns:
- the new value
-
divide
public short divide(short factor)
Description copied from class:SynchronizedShortDivide value by factor (i.e., set value /= factor)- Overrides:
dividein classSynchronizedShort- Returns:
- the new value
-
complement
public short complement()
Set the value to its complement- Overrides:
complementin classSynchronizedShort- Returns:
- the new value
-
and
public short and(short b)
Set value to value & b.- Overrides:
andin classSynchronizedShort- Returns:
- the new value
-
or
public short or(short b)
Set value to value | b.- Overrides:
orin classSynchronizedShort- Returns:
- the new value
-
xor
public short xor(short b)
Set value to value ^ b.- Overrides:
xorin classSynchronizedShort- Returns:
- the new value
-
whenEqual
public void whenEqual(short c, Runnable action) throws InterruptedExceptionWait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenNotEqual
public void whenNotEqual(short c, Runnable action) throws InterruptedExceptionwait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenLessEqual
public void whenLessEqual(short c, Runnable action) throws InterruptedExceptionwait until value less than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenLess
public void whenLess(short c, Runnable action) throws InterruptedExceptionwait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenGreaterEqual
public void whenGreaterEqual(short c, Runnable action) throws InterruptedExceptionwait until value greater than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenGreater
public void whenGreater(short c, Runnable action) throws InterruptedExceptionwait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
-