Class WaitableByte
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
EDU.oswego.cs.dl.util.concurrent.SynchronizedByte
EDU.oswego.cs.dl.util.concurrent.WaitableByte
- All Implemented Interfaces:
Executor, Cloneable, Comparable
A class useful for offloading waiting and signalling operations
on single byte variables.
-
Field Summary
Fields inherited from class SynchronizedByte
value_Fields inherited from class SynchronizedVariable
lock_ -
Constructor Summary
ConstructorsConstructorDescriptionWaitableByte(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
Modifier and TypeMethodDescriptionbyteadd(byte amount) Add amount to value (i.e., set value += amount)byteand(byte b) Set value to value & b.booleancommit(byte assumedValue, byte newValue) Set value to newValue only if it is currently assumedValue.byteSet the value to its complementbyteDecrement the value.bytedivide(byte factor) Divide value by factor (i.e., set value /= factor)byteIncrement the value.bytemultiply(byte factor) Multiply value by factor (i.e., set value *= factor)byteor(byte b) Set value to value | b.byteset(byte newValue) Set to newValue.bytesubtract(byte amount) Subtract amount from value (i.e., set value -= amount)voidWait until value equals c, then run action if nonnull.voidwhenGreater(byte c, Runnable action) wait until value greater than c, then run action if nonnull.voidwhenGreaterEqual(byte c, Runnable action) wait until value greater than or equal to c, then run action if nonnull.voidwait until value less than c, then run action if nonnull.voidwhenLessEqual(byte c, Runnable action) wait until value less than or equal to c, then run action if nonnull.voidwhenNotEqual(byte c, Runnable action) wait until value not equal to c, then run action if nonnull.bytexor(byte b) Set value to value ^ b.Methods inherited from class SynchronizedByte
compareTo, compareTo, compareTo, equals, get, hashCode, negate, swap, toStringMethods inherited from class 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
Make a new WaitableByte with the given initial value, and using the supplied lock.
-
-
Method Details
-
set
public byte set(byte newValue) Description copied from class:SynchronizedByteSet to newValue.- Overrides:
setin classSynchronizedByte- Returns:
- the old value
-
commit
public boolean commit(byte assumedValue, byte newValue) Description copied from class:SynchronizedByteSet value to newValue only if it is currently assumedValue.- Overrides:
commitin classSynchronizedByte- Returns:
- true if successful
-
increment
public byte increment()Description copied from class:SynchronizedByteIncrement the value.- Overrides:
incrementin classSynchronizedByte- Returns:
- the new value
-
decrement
public byte decrement()Description copied from class:SynchronizedByteDecrement the value.- Overrides:
decrementin classSynchronizedByte- Returns:
- the new value
-
add
public byte add(byte amount) Description copied from class:SynchronizedByteAdd amount to value (i.e., set value += amount)- Overrides:
addin classSynchronizedByte- Returns:
- the new value
-
subtract
public byte subtract(byte amount) Description copied from class:SynchronizedByteSubtract amount from value (i.e., set value -= amount)- Overrides:
subtractin classSynchronizedByte- Returns:
- the new value
-
multiply
public byte multiply(byte factor) Description copied from class:SynchronizedByteMultiply value by factor (i.e., set value *= factor)- Overrides:
multiplyin classSynchronizedByte- Returns:
- the new value
-
divide
public byte divide(byte factor) Description copied from class:SynchronizedByteDivide value by factor (i.e., set value /= factor)- Overrides:
dividein classSynchronizedByte- Returns:
- the new value
-
complement
public byte complement()Set the value to its complement- Overrides:
complementin classSynchronizedByte- Returns:
- the new value
-
and
public byte and(byte b) Set value to value & b.- Overrides:
andin classSynchronizedByte- Returns:
- the new value
-
or
public byte or(byte b) Set value to value | b.- Overrides:
orin classSynchronizedByte- Returns:
- the new value
-
xor
public byte xor(byte b) Set value to value ^ b.- Overrides:
xorin classSynchronizedByte- Returns:
- the new value
-
whenEqual
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenNotEqual
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenLessEqual
wait 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
wait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-
whenGreaterEqual
wait 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
wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.- Throws:
InterruptedException
-