Class WaitableRef

    • Constructor Summary

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

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean commit​(java.lang.Object assumedValue, java.lang.Object newValue)
      Set value to newValue only if it is currently assumedValue.
      java.lang.Object set​(java.lang.Object newValue)
      Set to newValue.
      void whenEqual​(java.lang.Object c, java.lang.Runnable action)
      Wait until value equals c, then run action if nonnull.
      void whenNotEqual​(java.lang.Object c, java.lang.Runnable action)
      wait until value not equal to c, then run action if nonnull.
      void whenNotNull​(java.lang.Runnable action)
      wait until value is nonnull, then run action if nonnull.
      void whenNull​(java.lang.Runnable action)
      Wait until value is null, then run action if nonnull.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • WaitableRef

        public WaitableRef​(java.lang.Object initialValue)
        Create a WaitableRef initially holding the given reference and using its own internal lock.
      • WaitableRef

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

      • set

        public java.lang.Object set​(java.lang.Object newValue)
        Description copied from class: SynchronizedRef
        Set to newValue.
        Overrides:
        set in class SynchronizedRef
        Returns:
        the old value
      • commit

        public boolean commit​(java.lang.Object assumedValue,
                              java.lang.Object newValue)
        Description copied from class: SynchronizedRef
        Set value to newValue only if it is currently assumedValue.
        Overrides:
        commit in class SynchronizedRef
        Returns:
        true if successful
      • whenNull

        public void whenNull​(java.lang.Runnable action)
                      throws java.lang.InterruptedException
        Wait until value is null, then run action if nonnull. The action is run with the synchronization lock held.
        Throws:
        java.lang.InterruptedException
      • whenNotNull

        public void whenNotNull​(java.lang.Runnable action)
                         throws java.lang.InterruptedException
        wait until value is nonnull, then run action if nonnull. The action is run with the synchronization lock held.
        Throws:
        java.lang.InterruptedException
      • whenEqual

        public void whenEqual​(java.lang.Object 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​(java.lang.Object 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