EDU.oswego.cs.dl.util.concurrent

Class WaitableFloat

Implemented Interfaces:
Cloneable, Comparable, Executor

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, Object lock)
Make a new WaitableFloat with the given initial value, and using the supplied lock.

Method Summary

float
add(float amount)
boolean
commit(float assumedValue, float newValue)
float
divide(float factor)
float
multiply(float factor)
float
set(float newValue)
float
subtract(float amount)
void
whenEqual(float c, Runnable action)
Wait until value equals c, then run action if nonnull.
void
whenGreater(float c, Runnable action)
wait until value greater than c, then run action if nonnull.
void
whenGreaterEqual(float c, Runnable action)
wait until value greater than or equal to c, then run action if nonnull.
void
whenLess(float c, Runnable action)
wait until value less than c, then run action if nonnull.
void
whenLessEqual(float c, Runnable action)
wait until value less than or equal to c, then run action if nonnull.
void
whenNotEqual(float c, 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

add, commit, compareTo, compareTo, compareTo, divide, equals, get, hashCode, multiply, set, subtract, swap, toString

Methods inherited from class EDU.oswego.cs.dl.util.concurrent.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

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

Method Details

add

public float add(float amount)
Overrides:
add in interface SynchronizedFloat

commit

public boolean commit(float assumedValue,
                      float newValue)
Overrides:
commit in interface SynchronizedFloat

divide

public float divide(float factor)
Overrides:
divide in interface SynchronizedFloat

multiply

public float multiply(float factor)
Overrides:
multiply in interface SynchronizedFloat

set

public float set(float newValue)
Overrides:
set in interface SynchronizedFloat

subtract

public float subtract(float amount)
Overrides:
subtract in interface SynchronizedFloat

whenEqual

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

whenGreater

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

whenGreaterEqual

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

whenLess

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

whenLessEqual

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

whenNotEqual

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