Class WaitableBoolean

    • Constructor Summary

      Constructors 
      Constructor Description
      WaitableBoolean​(boolean initialValue)
      Make a new WaitableBoolean with the given initial value *
      WaitableBoolean​(boolean initialValue, java.util.concurrent.locks.ReadWriteLock lock)
      Make a new WaitableBoolean with the given initial value, and using the supplied lock.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      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 equals​(java.lang.Object other)
      int hashCode()
      boolean or​(boolean b)
      Set value to value | b.
      boolean set​(boolean newValue)
      Set to newValue.
      void waitForChange()
      Waits for the value to change for up to 5secs.
      void whenEqual​(boolean c, java.lang.Runnable action)
      Wait until value equals c, then run action if nonnull.
      void whenFalse​(java.lang.Runnable action)
      Wait until value is false, then run action if nonnull.
      void whenNotEqual​(boolean c, java.lang.Runnable action)
      wait until value not equal to c, then run action if nonnull.
      void whenTrue​(java.lang.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 java.lang.Object

        clone, finalize, 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,
                               java.util.concurrent.locks.ReadWriteLock lock)
        Make a new WaitableBoolean with the given initial value, and using the supplied lock.
    • Method Detail

      • 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
        Returns:
        true if successful
      • whenFalse

        public void whenFalse​(java.lang.Runnable action)
                       throws java.lang.InterruptedException
        Wait until value is false, then run action if nonnull. The action is run with the synchronization lock held.
        Throws:
        java.lang.InterruptedException
      • whenTrue

        public void whenTrue​(java.lang.Runnable action)
                      throws java.lang.InterruptedException
        wait until value is true, then run action if nonnull. The action is run with the synchronization lock held.
        Throws:
        java.lang.InterruptedException
      • whenEqual

        public void whenEqual​(boolean 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​(boolean 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
      • waitForChange

        public void waitForChange()
                           throws java.lang.InterruptedException
        Waits for the value to change for up to 5secs. State must be re-checked after this method returns.
        Throws:
        java.lang.InterruptedException