public abstract class CopyOnWriteManager<E> extends Object implements Cloneable
CopyOnWriteManager also manages
a running total that represents the size of the contained tree structure.
Users should implement the freezeAndClone(Object) and
cloneFrozen(Object) methods.
| Constructor and Description |
|---|
CopyOnWriteManager(E initialValue,
int initialSize)
|
| Modifier and Type | Method and Description |
|---|---|
E |
availableFrozen()
Returns a reference to a snapshot of this instance's tree structure,
if one is available without requiring any additional copying, otherwise
returns null.
|
Epoch.Ticket |
beginMutation()
Obtains permission to mutate the copy-on-write value held by this
instance, perhaps blocking while a concurrent snapshot is being
performed.
|
Epoch.Ticket |
beginQuiescent() |
CopyOnWriteManager<E> |
clone() |
protected abstract E |
cloneFrozen(E frozenValue)
Returns a clone of a frozen E.
|
protected abstract E |
freezeAndClone(E value)
The implementing method must mark
value as shared, and
return a new object to use in its place. |
E |
frozen()
Returns a reference to a snapshot of this instance's tree structure
that may be read, but not written.
|
boolean |
isEmpty()
Returns true if the computed
size() is zero. |
E |
mutable()
Returns a reference to the tree structure suitable for a mutating
operation.
|
E |
read()
Returns a reference to the tree structure suitable for a read
operation.
|
int |
size()
Returns the sum of the
initialSize parameter passed to the
constructor, and the size deltas passed to Epoch.Ticket.leave(int)
for all of the mutation tickets. |
public CopyOnWriteManager(E initialValue, int initialSize)
protected abstract E freezeAndClone(E value)
value as shared, and
return a new object to use in its place. Hopefully, the majority of
the work of the clone can be deferred by copy-on-write.public CopyOnWriteManager<E> clone()
public E read()
CopyOnWriteManager, but they will
not observe changes managed by other instances.public Epoch.Ticket beginMutation()
Epoch.Ticket.leave(int) must be called exactly once on
the object returned from this method, after the mutation has been
completed. The change in size reflected by the mutation should be
passed as the parameter to leave.public Epoch.Ticket beginQuiescent()
public E mutable()
beginMutation().public E frozen()
freezeAndClone(root, false), and then returning a
reference to the old root. Successive calls to this method may return
the same instance.public E availableFrozen()
beginQuiescent()
to perform quiescent reads with minimal cost.public boolean isEmpty()
size() is zero.public int size()
initialSize parameter passed to the
constructor, and the size deltas passed to Epoch.Ticket.leave(int)
for all of the mutation tickets. The result returned is linearizable
with mutations, which requires mutation to be quiesced. No tree freeze
is required, however.
Follow @ApacheIgnite
Ignite Fabric : ver. 1.6.0 Release Date : May 18 2016