## EDU.oswego.cs.dl.util.concurrent
Class WaitableRef

    java.lang.Object
      EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
          EDU.oswego.cs.dl.util.concurrent.SynchronizedRef
              EDU.oswego.cs.dl.util.concurrent.WaitableRef

All Implemented Interfaces:
  Executor

    public class WaitableRef

extends SynchronizedRef

A class useful for offloading synch for Object reference instance variables.

[ Introduction to this package. ]

Field Summary

Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedRef
`value_`

Fields inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
`lock_`

Constructor Summary
`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
`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 EDU.oswego.cs.dl.util.concurrent.SynchronizedRef
`get, swap`

Methods inherited from class EDU.oswego.cs.dl.util.concurrent.SynchronizedVariable
`execute, getLock`

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`