Class WaitableFloat
java.lang.Object
EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
EDU.oswego.cs.dl.util.concurrent.SynchronizedFloat
EDU.oswego.cs.dl.util.concurrent.WaitableFloat
- All Implemented Interfaces:
Executor, Cloneable, Comparable
A class useful for offloading waiting and signalling operations
on single float variables.
-
Field Summary
Fields inherited from class SynchronizedFloat
value_Fields inherited from class SynchronizedVariable
lock_ -
Constructor Summary
ConstructorsConstructorDescriptionWaitableFloat(float initialValue) Make a new WaitableFloat with the given initial value, and using its own internal lock.WaitableFloat(float initialValue, Object lock) Make a new WaitableFloat with the given initial value, and using the supplied lock. -
Method Summary
Modifier and TypeMethodDescriptionfloatadd(float amount) Add amount to value (i.e., set value += amount)booleancommit(float assumedValue, float newValue) Set value to newValue only if it is currently assumedValue.floatdivide(float factor) Divide value by factor (i.e., set value /= factor)floatmultiply(float factor) Multiply value by factor (i.e., set value *= factor)floatset(float newValue) Set to newValue.floatsubtract(float amount) Subtract amount from value (i.e., set value -= amount)voidWait until value equals c, then run action if nonnull.voidwhenGreater(float c, Runnable action) wait until value greater than c, then run action if nonnull.voidwhenGreaterEqual(float 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(float c, Runnable action) wait until value less than or equal to c, then run action if nonnull.voidwhenNotEqual(float c, Runnable action) wait until value not equal to c, then run action if nonnull.Methods inherited from class SynchronizedFloat
compareTo, compareTo, compareTo, equals, get, hashCode, swap, toStringMethods inherited from class SynchronizedVariable
execute, getLock
-
Constructor Details
-
WaitableFloat
public WaitableFloat(float initialValue) Make a new WaitableFloat with the given initial value, and using its own internal lock. -
WaitableFloat
Make a new WaitableFloat with the given initial value, and using the supplied lock.
-
-
Method Details
-
set
public float set(float newValue) Description copied from class:SynchronizedFloatSet to newValue.- Overrides:
setin classSynchronizedFloat- Returns:
- the old value
-
commit
public boolean commit(float assumedValue, float newValue) Description copied from class:SynchronizedFloatSet value to newValue only if it is currently assumedValue.- Overrides:
commitin classSynchronizedFloat- Returns:
- true if successful
-
add
public float add(float amount) Description copied from class:SynchronizedFloatAdd amount to value (i.e., set value += amount)- Overrides:
addin classSynchronizedFloat- Returns:
- the new value
-
subtract
public float subtract(float amount) Description copied from class:SynchronizedFloatSubtract amount from value (i.e., set value -= amount)- Overrides:
subtractin classSynchronizedFloat- Returns:
- the new value
-
multiply
public float multiply(float factor) Description copied from class:SynchronizedFloatMultiply value by factor (i.e., set value *= factor)- Overrides:
multiplyin classSynchronizedFloat- Returns:
- the new value
-
divide
public float divide(float factor) Description copied from class:SynchronizedFloatDivide value by factor (i.e., set value /= factor)- Overrides:
dividein classSynchronizedFloat- 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
-