org.multiverse.transactional.refs
Interface Ref<E>

All Known Implementing Classes:
AbaRef, BasicRef

public interface Ref<E>

The Ref is responsible for storing a value while providing transactional guarantees (failure atomicity, isolation)

Timed versions of the getOrAwait methods will be added in the near future.

Author:
Peter Veentjer

Method Summary
 E clear()
          Clears the value and returns the old value (could be null).
 E get()
          Gets the current value stored in this reference.
 E getOrAwait()
          Gets the current non null value, or waits until a non null value comes available.
 E getOrAwaitInterruptibly()
          Gets the current non null value, or waits until a non null value becomes available or until it is is Interrupted.
 boolean isNull()
          Checks if the value is null.
 E set(E newValue)
          Sets the new value value.
 

Method Detail

get

E get()
Gets the current value stored in this reference.

Returns:
the current value.

getOrAwait

E getOrAwait()
Gets the current non null value, or waits until a non null value comes available. So you will always get a non null ref.

This call is not interruptible, unless the enclosing transaction is configured as interruptible.

Returns:
the current stored reference.

getOrAwaitInterruptibly

E getOrAwaitInterruptibly()
                          throws java.lang.InterruptedException
Gets the current non null value, or waits until a non null value becomes available or until it is is Interrupted.

This call is interruptible, unless the enclosing transaction isn't configured as interruptible.

Returns:
the current stored reference.
Throws:
java.lang.InterruptedException - if the thread is interrupted while waiting on a reference to come available.

set

E set(E newValue)
Sets the new value value. The value is allowed to be null.

Parameters:
newValue - the new value
Returns:
the previous value, which could be null.

clear

E clear()
Clears the value and returns the old value (could be null).

Returns:
the old value.

isNull

boolean isNull()
Checks if the value is null.

Returns:
true if the value is null, false otherwise.


Copyright © 2008-2010 Multiverse. All Rights Reserved.