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>

public class ReadHeavyLongArray<V> extends AbstractSafeLongArray<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:
  • Field Details

    • f_lockWrite

      protected final com.oracle.coherence.common.util.AutoLock<LongArray<V>> f_lockWrite
      The write lock, delegating to the one in the super class.
    • f_lockReadRaw

      protected final Lock f_lockReadRaw
      The raw read lock.
    • m_lockRead

      protected volatile com.oracle.coherence.common.util.AutoLock<LongArray<V>> m_lockRead
      The mutable read lock.
    • m_cReads

      protected long m_cReads
      The (dirty) total number of reads.
    • m_cReadTrigger

      protected long m_cReadTrigger
      The read count at which to trigger a switch to a lock-free delegate.
  • Constructor Details

    • ReadHeavyLongArray

      public ReadHeavyLongArray()
      Construct a ReadHeavyLongArray.
    • ReadHeavyLongArray

      public ReadHeavyLongArray(LongArray<V> delegate)
      Construct a ReadHeavyLongArray around the specified delegate.
      Parameters:
      delegate - the delegate long array, it is not safe to externally access this array
  • Method Details