Class SafeLongArray<V>

java.lang.Object
com.tangosol.util.AbstractSafeLongArray<V>
com.tangosol.util.SafeLongArray<V>
All Implemented Interfaces:
LongArray<V>, Serializable, Cloneable, Iterable<V>

public class SafeLongArray<V> extends AbstractSafeLongArray<V>
A thread-safe variant of LongArray in which is protected by a ReentrantLock. This implementation is suitable for workloads where the read to write ratio is close to 1:1, or where writes are more common then reads. For read heavy workloads the ReadHeavyLongArray is likely to be a better choice.
Author:
mf 2014.10.01
See Also:
  • Field Details

    • f_lock

      protected final com.oracle.coherence.common.util.AutoLock<LongArray<V>> f_lock
      The lock to hold during read and write operations.
  • Constructor Details

    • SafeLongArray

      public SafeLongArray()
      Construct a new SafeLongArray.
    • SafeLongArray

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

    • getLock

      public com.oracle.coherence.common.util.AutoLock<LongArray<V>> getLock()
      Return the lock used to protect this LongArray, with the unsafe delegate as its resource.

      Explicit usage of this lock is only necessary when performing multiple sequential operations against the LongArray which need to be "atomic".

      Returns:
      the lock
    • clone

      public SafeLongArray<V> clone()
      Description copied from interface: LongArray
      Make a clone of the LongArray. The element values are not deep-cloned.
      Specified by:
      clone in interface LongArray<V>
      Specified by:
      clone in class AbstractSafeLongArray<V>
      Returns:
      a clone of this LongArray object
    • acquireReadLock

      protected com.oracle.coherence.common.util.AutoLock.Sentry<LongArray<V>> acquireReadLock()
      Description copied from class: AbstractSafeLongArray
      Acquire the read lock.
      Specified by:
      acquireReadLock in class AbstractSafeLongArray<V>
      Returns:
      the lock sentry
    • acquireWriteLock

      protected com.oracle.coherence.common.util.AutoLock.Sentry<LongArray<V>> acquireWriteLock()
      Description copied from class: AbstractSafeLongArray
      Acquire the write lock.
      Specified by:
      acquireWriteLock in class AbstractSafeLongArray<V>
      Returns:
      the lock sentry