Class WaitableDouble

    • Constructor Summary

      Constructors 
      Constructor Description
      WaitableDouble​(double initialValue)
      Make a new WaitableDouble with the given initial value, and using its own internal lock.
      WaitableDouble​(double initialValue, java.lang.Object lock)
      Make a new WaitableDouble with the given initial value, and using the supplied lock.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      double add​(double amount)
      Add amount to value (i.e., set value += amount)
      boolean commit​(double assumedValue, double newValue)
      Set value to newValue only if it is currently assumedValue.
      double divide​(double factor)
      Divide value by factor (i.e., set value /= factor)
      double multiply​(double factor)
      Multiply value by factor (i.e., set value *= factor)
      double set​(double newValue)
      Set to newValue.
      double subtract​(double amount)
      Subtract amount from value (i.e., set value -= amount)
      void whenEqual​(double c, java.lang.Runnable action)
      Wait until value equals c, then run action if nonnull.
      void whenGreater​(double c, java.lang.Runnable action)
      wait until value greater than c, then run action if nonnull.
      void whenGreaterEqual​(double c, java.lang.Runnable action)
      wait until value greater than or equal to c, then run action if nonnull.
      void whenLess​(double c, java.lang.Runnable action)
      wait until value less than c, then run action if nonnull.
      void whenLessEqual​(double c, java.lang.Runnable action)
      wait until value less than or equal to c, then run action if nonnull.
      void whenNotEqual​(double c, java.lang.Runnable action)
      wait until value not equal to c, then run action if nonnull.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • WaitableDouble

        public WaitableDouble​(double initialValue)
        Make a new WaitableDouble with the given initial value, and using its own internal lock.
      • WaitableDouble

        public WaitableDouble​(double initialValue,
                              java.lang.Object lock)
        Make a new WaitableDouble with the given initial value, and using the supplied lock.
    • Method Detail

      • commit

        public boolean commit​(double assumedValue,
                              double newValue)
        Description copied from class: SynchronizedDouble
        Set value to newValue only if it is currently assumedValue.
        Overrides:
        commit in class SynchronizedDouble
        Returns:
        true if successful
      • add

        public double add​(double amount)
        Description copied from class: SynchronizedDouble
        Add amount to value (i.e., set value += amount)
        Overrides:
        add in class SynchronizedDouble
        Returns:
        the new value
      • subtract

        public double subtract​(double amount)
        Description copied from class: SynchronizedDouble
        Subtract amount from value (i.e., set value -= amount)
        Overrides:
        subtract in class SynchronizedDouble
        Returns:
        the new value
      • multiply

        public double multiply​(double factor)
        Description copied from class: SynchronizedDouble
        Multiply value by factor (i.e., set value *= factor)
        Overrides:
        multiply in class SynchronizedDouble
        Returns:
        the new value
      • divide

        public double divide​(double factor)
        Description copied from class: SynchronizedDouble
        Divide value by factor (i.e., set value /= factor)
        Overrides:
        divide in class SynchronizedDouble
        Returns:
        the new value
      • whenEqual

        public void whenEqual​(double 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​(double 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​(double 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​(double 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​(double 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​(double 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