Class WaitableByte

    • Constructor Summary

      Constructors 
      Constructor Description
      WaitableByte​(byte initialValue)
      Make a new WaitableByte with the given initial value, and using its own internal lock.
      WaitableByte​(byte initialValue, Object lock)
      Make a new WaitableByte with the given initial value, and using the supplied lock.
    • Constructor Detail

      • WaitableByte

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

        public WaitableByte​(byte initialValue,
                            Object lock)
        Make a new WaitableByte with the given initial value, and using the supplied lock.
    • Method Detail

      • commit

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

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

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

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

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

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

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

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

        public byte xor​(byte b)
        Set value to value ^ b.
        Overrides:
        xor in class SynchronizedByte
        Returns:
        the new value
      • whenNotEqual

        public void whenNotEqual​(byte 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.
        Throws:
        InterruptedException
      • whenLessEqual

        public void whenLessEqual​(byte c,
                                  Runnable action)
                           throws 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:
        InterruptedException
      • whenGreaterEqual

        public void whenGreaterEqual​(byte c,
                                     Runnable action)
                              throws 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:
        InterruptedException
      • whenGreater

        public void whenGreater​(byte c,
                                Runnable action)
                         throws InterruptedException
        wait until value greater than c, then run action if nonnull. The action is run with the synchronization lock held.
        Throws:
        InterruptedException