Class WaitableShort

    • Constructor Summary

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

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

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

      • WaitableShort

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

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

      • commit

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

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

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

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

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

        public short complement()
        Set the value to its complement
        Overrides:
        complement in class SynchronizedShort
        Returns:
        the new value
      • and

        public short and​(short b)
        Set value to value & b.
        Overrides:
        and in class SynchronizedShort
        Returns:
        the new value
      • or

        public short or​(short b)
        Set value to value | b.
        Overrides:
        or in class SynchronizedShort
        Returns:
        the new value
      • xor

        public short xor​(short b)
        Set value to value ^ b.
        Overrides:
        xor in class SynchronizedShort
        Returns:
        the new value
      • whenEqual

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