public class ReadHeavyLongArray<V> extends AbstractSafeLongArray<V>
This implementation provides thread-safety via a combination of locking and copy-on-write. Unlike the
CopyOnWriteLongArray
it will in general allow for many mutations within a single copy. When
the read to write ratio is high enough (think thousands of reads per write) the read locks will be elided allowing
for maximum performance.
For workloads with a read to write ratio close to 1:1 or where writes are more common then reads
the SafeLongArray
may be more appropriate.
AbstractSafeLongArray.SafeIterator
LongArray.Iterator<V>
Modifier and Type | Field and Description |
---|---|
protected Lock |
f_lockReadRaw
The raw read lock.
|
protected com.oracle.coherence.common.util.AutoLock<LongArray<V>> |
f_lockWrite
The write lock, delegating to the one in the super class.
|
protected long |
m_cReads
The (dirty) total number of reads.
|
protected long |
m_cReadTrigger
The read count at which to trigger a switch to a lock-free delegate.
|
protected com.oracle.coherence.common.util.AutoLock<LongArray<V>> |
m_lockRead
The mutable read lock.
|
NO_VALUE
Constructor and Description |
---|
ReadHeavyLongArray()
Construct a ReadHeavyLongArray.
|
ReadHeavyLongArray(LongArray<V> delegate)
Construct a ReadHeavyLongArray around the specified delegate.
|
Modifier and Type | Method and Description |
---|---|
protected com.oracle.coherence.common.util.AutoLock.Sentry<LongArray<V>> |
acquireReadLock()
Acquire the read lock.
|
protected com.oracle.coherence.common.util.AutoLock.Sentry<LongArray<V>> |
acquireWriteLock()
Acquire the write lock.
|
ReadHeavyLongArray<V> |
clone()
Make a clone of the LongArray.
|
protected AbstractSafeLongArray.SafeIterator |
instantiateSafeIterator(boolean fForward,
long lIndexFrom)
Instantiate a SafeIterator around the specified delegate iterator.
|
add, ceiling, ceilingIndex, clear, contains, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, isEmpty, iterator, iterator, lastIndexOf, lastIndexOf, remove, remove, reverseIterator, reverseIterator, set, toString
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
forEach, spliterator
protected final com.oracle.coherence.common.util.AutoLock<LongArray<V>> f_lockWrite
protected final Lock f_lockReadRaw
protected volatile com.oracle.coherence.common.util.AutoLock<LongArray<V>> m_lockRead
protected long m_cReads
protected long m_cReadTrigger
public ReadHeavyLongArray<V> clone()
LongArray
protected com.oracle.coherence.common.util.AutoLock.Sentry<LongArray<V>> acquireReadLock()
AbstractSafeLongArray
acquireReadLock
in class AbstractSafeLongArray<V>
protected com.oracle.coherence.common.util.AutoLock.Sentry<LongArray<V>> acquireWriteLock()
AbstractSafeLongArray
acquireWriteLock
in class AbstractSafeLongArray<V>
protected AbstractSafeLongArray.SafeIterator instantiateSafeIterator(boolean fForward, long lIndexFrom)
AbstractSafeLongArray
instantiateSafeIterator
in class AbstractSafeLongArray<V>
fForward
- true if a forward iterator is to be returnedlIndexFrom
- the start index