Class WaitableChar

    • Constructor Summary

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

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

      • WaitableChar

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

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

      • commit

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

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

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

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

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

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