org.mapdb
Class Atomic.Var<E>

java.lang.Object
  extended by org.mapdb.Atomic.Var<E>
Enclosing class:
Atomic

public static final class Atomic.Var<E>
extends Object

Atomically updated variable which may contain any type of record.


Field Summary
protected  Engine engine
           
protected  long recid
           
protected  Serializer<E> serializer
           
 
Constructor Summary
  Atomic.Var(Engine engine, long recid, Serializer<E> serializer)
           
protected Atomic.Var(Engine engine, SerializerBase serializerBase, DataInput is, SerializerBase.FastArrayList<Object> objectStack)
          used for deserialization
 
Method Summary
 boolean compareAndSet(E expect, E update)
          Atomically sets the value to the given updated value if the current value equals the expected value.
 E get()
          Returns the current value.
 E getAndSet(E newValue)
          Atomically sets to the given value and returns the previous value.
 long getRecid()
           
 void set(E newValue)
          Unconditionally sets to the given value.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

engine

protected final Engine engine

recid

protected final long recid

serializer

protected final Serializer<E> serializer
Constructor Detail

Atomic.Var

public Atomic.Var(Engine engine,
                  long recid,
                  Serializer<E> serializer)

Atomic.Var

protected Atomic.Var(Engine engine,
                     SerializerBase serializerBase,
                     DataInput is,
                     SerializerBase.FastArrayList<Object> objectStack)
              throws IOException
used for deserialization

Throws:
IOException
Method Detail

getRecid

public long getRecid()
Returns:
recid under which value is saved

toString

public String toString()
Overrides:
toString in class Object

get

public final E get()
Returns the current value.

Returns:
the current value

compareAndSet

public final boolean compareAndSet(E expect,
                                   E update)
Atomically sets the value to the given updated value if the current value equals the expected value.

Parameters:
expect - the expected value
update - the new value
Returns:
true if successful. False return indicates that the actual value was not equal to the expected value.

set

public final void set(E newValue)
Unconditionally sets to the given value.

Parameters:
newValue - the new value

getAndSet

public final E getAndSet(E newValue)
Atomically sets to the given value and returns the previous value.

Parameters:
newValue - the new value
Returns:
the previous value


Copyright © 2014. All Rights Reserved.