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