Class WaitableLong

    • Constructor Summary

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

      • WaitableLong

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

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

      • commit

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

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

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

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

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

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

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

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

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

        public void whenNotEqual​(long 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​(long 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​(long 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​(long 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