edu.rice.cs.plt.concurrent
Class ConcurrentBox<T>

java.lang.Object
  extended by java.util.concurrent.atomic.AtomicReference<T>
      extended by edu.rice.cs.plt.concurrent.ConcurrentBox<T>
All Implemented Interfaces:
Box<T>, Thunk<T>, java.io.Serializable

public class ConcurrentBox<T>
extends java.util.concurrent.atomic.AtomicReference<T>
implements Box<T>

A thread-safe box implementation. Extends AtomicReference so that it can be treated as a Box.

As a wrapper for arbitrary objects, instances of this class will serialize without error only if the wrapped object is serializable.

See Also:
Serialized Form

Constructor Summary
ConcurrentBox()
          Create a box initialized with null
ConcurrentBox(T val)
          Create a box initialized with val
 
Method Summary
static
<T> ConcurrentBox<T>
make()
          Call the constructor (allows T to be inferred)
static
<T> ConcurrentBox<T>
make(T val)
          Call the constructor (allows T to be inferred)
 T value()
           
 
Methods inherited from class java.util.concurrent.atomic.AtomicReference
compareAndSet, get, getAndSet, lazySet, set, toString, weakCompareAndSet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface edu.rice.cs.plt.lambda.Box
set
 

Constructor Detail

ConcurrentBox

public ConcurrentBox(T val)
Create a box initialized with val


ConcurrentBox

public ConcurrentBox()
Create a box initialized with null

Method Detail

value

public T value()
Specified by:
value in interface Thunk<T>

make

public static <T> ConcurrentBox<T> make(T val)
Call the constructor (allows T to be inferred)


make

public static <T> ConcurrentBox<T> make()
Call the constructor (allows T to be inferred)