Colt 1.0.2

edu.oswego.cs.dl.util.concurrent
Class WaitableBoolean

java.lang.Object
  |
  +--edu.oswego.cs.dl.util.concurrent.SynchronizedVariable
        |
        +--edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
              |
              +--edu.oswego.cs.dl.util.concurrent.WaitableBoolean
All Implemented Interfaces:
Cloneable, Comparable, Executor

public class WaitableBoolean
extends SynchronizedBoolean

A class useful for offloading synch for boolean instance variables.

[ Introduction to this package. ]


Constructor Summary
WaitableBoolean(boolean initialValue)
          Make a new WaitableBoolean with the given initial value
WaitableBoolean(boolean initialValue, Object lock)
          Make a new WaitableBoolean with the given initial value, and using the supplied lock.
 
Method Summary
 boolean and(boolean b)
          Set value to value & b.
 boolean commit(boolean assumedValue, boolean newValue)
          Set value to newValue only if it is currently assumedValue.
 boolean complement()
          Set the value to its complement
 boolean or(boolean b)
          Set value to value | b.
 boolean set(boolean newValue)
          Set to newValue.
 void whenEqual(boolean c, Runnable action)
          Wait until value equals c, then run action if nonnull.
 void whenFalse(Runnable action)
          Wait until value is false, then run action if nonnull.
 void whenNotEqual(boolean c, Runnable action)
          wait until value not equal to c, then run action if nonnull.
 void whenTrue(Runnable action)
          wait until value is true, then run action if nonnull.
 boolean xor(boolean b)
          Set value to value ^ b.
 
Methods inherited from class edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
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
getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

WaitableBoolean

public WaitableBoolean(boolean initialValue)
Make a new WaitableBoolean with the given initial value

WaitableBoolean

public WaitableBoolean(boolean initialValue,
                       Object lock)
Make a new WaitableBoolean with the given initial value, and using the supplied lock.
Method Detail

and

public boolean and(boolean b)
Description copied from class: SynchronizedBoolean
Set value to value & b.
Overrides:
and in class SynchronizedBoolean
Following copied from class: edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
Returns:
the new value

commit

public boolean commit(boolean assumedValue,
                      boolean newValue)
Description copied from class: SynchronizedBoolean
Set value to newValue only if it is currently assumedValue.
Overrides:
commit in class SynchronizedBoolean
Following copied from class: edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
Returns:
true if successful

complement

public boolean complement()
Description copied from class: SynchronizedBoolean
Set the value to its complement
Overrides:
complement in class SynchronizedBoolean
Following copied from class: edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
Returns:
the new value

or

public boolean or(boolean b)
Description copied from class: SynchronizedBoolean
Set value to value | b.
Overrides:
or in class SynchronizedBoolean
Following copied from class: edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
Returns:
the new value

set

public boolean set(boolean newValue)
Description copied from class: SynchronizedBoolean
Set to newValue.
Overrides:
set in class SynchronizedBoolean
Following copied from class: edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
Returns:
the old value

whenEqual

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

whenFalse

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

whenNotEqual

public void whenNotEqual(boolean 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.

whenTrue

public void whenTrue(Runnable action)
              throws InterruptedException
wait until value is true, then run action if nonnull. The action is run with the synchronization lock held.

xor

public boolean xor(boolean b)
Description copied from class: SynchronizedBoolean
Set value to value ^ b.
Overrides:
xor in class SynchronizedBoolean
Following copied from class: edu.oswego.cs.dl.util.concurrent.SynchronizedBoolean
Returns:
the new value

Colt 1.0.2

Submit a bug or feature. Check the Colt home page for the latest news.