EDU.oswego.cs.dl.util.concurrent
Class WaitableFloat

java.lang.Object
  extended by EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
      extended by EDU.oswego.cs.dl.util.concurrent.SynchronizedFloat
          extended by EDU.oswego.cs.dl.util.concurrent.WaitableFloat
All Implemented Interfaces:
Executor, java.lang.Cloneable, java.lang.Comparable

public class WaitableFloat
extends SynchronizedFloat

A class useful for offloading waiting and signalling operations on single float variables.

[ Introduction to this package. ]


Field Summary
 
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedFloat
value_
 
Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
lock_
 
Constructor Summary
WaitableFloat(float initialValue)
          Make a new WaitableFloat with the given initial value, and using its own internal lock.
WaitableFloat(float initialValue, java.lang.Object lock)
          Make a new WaitableFloat with the given initial value, and using the supplied lock.
 
Method Summary
 float add(float amount)
          Add amount to value (i.e., set value += amount)
 boolean commit(float assumedValue, float newValue)
          Set value to newValue only if it is currently assumedValue.
 float divide(float factor)
          Divide value by factor (i.e., set value /= factor)
 float multiply(float factor)
          Multiply value by factor (i.e., set value *= factor)
 float set(float newValue)
          Set to newValue.
 float subtract(float amount)
          Subtract amount from value (i.e., set value -= amount)
 void whenEqual(float c, java.lang.Runnable action)
          Wait until value equals c, then run action if nonnull.
 void whenGreater(float c, java.lang.Runnable action)
          wait until value greater than c, then run action if nonnull.
 void whenGreaterEqual(float c, java.lang.Runnable action)
          wait until value greater than or equal to c, then run action if nonnull.
 void whenLess(float c, java.lang.Runnable action)
          wait until value less than c, then run action if nonnull.
 void whenLessEqual(float c, java.lang.Runnable action)
          wait until value less than or equal to c, then run action if nonnull.
 void whenNotEqual(float c, java.lang.Runnable action)
          wait until value not equal to c, then run action if nonnull.
 
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedFloat
compareTo, compareTo, compareTo, equals, get, hashCode, swap, toString
 
Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
execute, getLock
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WaitableFloat

public WaitableFloat(float initialValue)
Make a new WaitableFloat with the given initial value, and using its own internal lock.


WaitableFloat

public WaitableFloat(float initialValue,
                     java.lang.Object lock)
Make a new WaitableFloat with the given initial value, and using the supplied lock.

Method Detail

set

public float set(float newValue)
Description copied from class: SynchronizedFloat
Set to newValue.

Overrides:
set in class SynchronizedFloat
Returns:
the old value

commit

public boolean commit(float assumedValue,
                      float newValue)
Description copied from class: SynchronizedFloat
Set value to newValue only if it is currently assumedValue.

Overrides:
commit in class SynchronizedFloat
Returns:
true if successful

add

public float add(float amount)
Description copied from class: SynchronizedFloat
Add amount to value (i.e., set value += amount)

Overrides:
add in class SynchronizedFloat
Returns:
the new value

subtract

public float subtract(float amount)
Description copied from class: SynchronizedFloat
Subtract amount from value (i.e., set value -= amount)

Overrides:
subtract in class SynchronizedFloat
Returns:
the new value

multiply

public float multiply(float factor)
Description copied from class: SynchronizedFloat
Multiply value by factor (i.e., set value *= factor)

Overrides:
multiply in class SynchronizedFloat
Returns:
the new value

divide

public float divide(float factor)
Description copied from class: SynchronizedFloat
Divide value by factor (i.e., set value /= factor)

Overrides:
divide in class SynchronizedFloat
Returns:
the new value

whenEqual

public void whenEqual(float c,
                      java.lang.Runnable action)
               throws java.lang.InterruptedException
Wait until value equals c, then run action if nonnull. The action is run with the synchronization lock held.

Throws:
java.lang.InterruptedException

whenNotEqual

public void whenNotEqual(float c,
                         java.lang.Runnable action)
                  throws java.lang.InterruptedException
wait until value not equal to c, then run action if nonnull. The action is run with the synchronization lock held.

Throws:
java.lang.InterruptedException

whenLessEqual

public void whenLessEqual(float c,
                          java.lang.Runnable action)
                   throws java.lang.InterruptedException
wait until value less than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.

Throws:
java.lang.InterruptedException

whenLess

public void whenLess(float c,
                     java.lang.Runnable action)
              throws java.lang.InterruptedException
wait until value less than c, then run action if nonnull. The action is run with the synchronization lock held.

Throws:
java.lang.InterruptedException

whenGreaterEqual

public void whenGreaterEqual(float c,
                             java.lang.Runnable action)
                      throws java.lang.InterruptedException
wait until value greater than or equal to c, then run action if nonnull. The action is run with the synchronization lock held.

Throws:
java.lang.InterruptedException

whenGreater

public void whenGreater(float c,
                        java.lang.Runnable action)
                 throws java.lang.InterruptedException
wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.

Throws:
java.lang.InterruptedException