Package com.tangosol.util
Class ReadHeavyLongArray<V>
java.lang.Object
com.tangosol.util.AbstractSafeLongArray<V>
com.tangosol.util.ReadHeavyLongArray<V>
- All Implemented Interfaces:
 LongArray<V>,Serializable,Cloneable,Iterable<V>
A thread-safe LongArray implementation for read heavy workloads but which is also efficient with frequent and/or
 bursty writes.
 
 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.
- Author:
 - mf 2014.10.02
 - See Also:
 
- 
Nested Class Summary
Nested classes/interfaces inherited from class com.tangosol.util.AbstractSafeLongArray
AbstractSafeLongArray.SafeIteratorNested classes/interfaces inherited from interface com.tangosol.util.LongArray
LongArray.Iterator<V> - 
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final LockThe raw read lock.The write lock, delegating to the one in the super class.protected longThe (dirty) total number of reads.protected longThe read count at which to trigger a switch to a lock-free delegate.The mutable read lock.Fields inherited from class com.tangosol.util.AbstractSafeLongArray
NO_VALUE - 
Constructor Summary
ConstructorsConstructorDescriptionConstruct a ReadHeavyLongArray.ReadHeavyLongArray(LongArray<V> delegate) Construct a ReadHeavyLongArray around the specified delegate. - 
Method Summary
Modifier and TypeMethodDescriptionAcquire the read lock.Acquire the write lock.clone()Make a clone of the LongArray.protected AbstractSafeLongArray<V>.SafeIteratorinstantiateSafeIterator(boolean fForward, long lIndexFrom) Instantiate a SafeIterator around the specified delegate iterator.Methods inherited from class com.tangosol.util.AbstractSafeLongArray
add, ceiling, ceilingIndex, clear, contains, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, isEmpty, iterator, iterator, lastIndexOf, lastIndexOf, remove, remove, reverseIterator, reverseIterator, set, toStringMethods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator 
- 
Field Details
- 
f_lockWrite
The write lock, delegating to the one in the super class. - 
f_lockReadRaw
The raw read lock. - 
m_lockRead
The mutable read lock. - 
m_cReads
protected long m_cReadsThe (dirty) total number of reads. - 
m_cReadTrigger
protected long m_cReadTriggerThe read count at which to trigger a switch to a lock-free delegate. 
 - 
 - 
Constructor Details
- 
ReadHeavyLongArray
public ReadHeavyLongArray()Construct a ReadHeavyLongArray. - 
ReadHeavyLongArray
Construct a ReadHeavyLongArray around the specified delegate.- Parameters:
 delegate- the delegate long array, it is not safe to externally access this array
 
 - 
 - 
Method Details
- 
clone
Description copied from interface:LongArrayMake a clone of the LongArray. The element values are not deep-cloned. - 
acquireReadLock
Description copied from class:AbstractSafeLongArrayAcquire the read lock.- Specified by:
 acquireReadLockin classAbstractSafeLongArray<V>- Returns:
 - the lock sentry
 
 - 
acquireWriteLock
Description copied from class:AbstractSafeLongArrayAcquire the write lock.- Specified by:
 acquireWriteLockin classAbstractSafeLongArray<V>- Returns:
 - the lock sentry
 
 - 
instantiateSafeIterator
protected AbstractSafeLongArray<V>.SafeIterator instantiateSafeIterator(boolean fForward, long lIndexFrom) Description copied from class:AbstractSafeLongArrayInstantiate a SafeIterator around the specified delegate iterator.- Overrides:
 instantiateSafeIteratorin classAbstractSafeLongArray<V>- Parameters:
 fForward- true if a forward iterator is to be returnedlIndexFrom- the start index- Returns:
 - the safe iterator
 
 
 -