Package com.tangosol.util
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 ofLongArray
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 theReadHeavyLongArray
is likely to be a better choice.- Author:
- mf 2014.10.01
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class com.tangosol.util.AbstractSafeLongArray
AbstractSafeLongArray.SafeIterator
-
Nested classes/interfaces inherited from interface com.tangosol.util.LongArray
LongArray.Iterator<V>
-
-
Field Summary
Fields Modifier and Type Field Description protected com.oracle.coherence.common.util.AutoLock<LongArray<V>>
f_lock
The lock to hold during read and write operations.-
Fields inherited from class com.tangosol.util.AbstractSafeLongArray
NO_VALUE
-
-
Constructor Summary
Constructors Constructor Description SafeLongArray()
Construct a new SafeLongArray.SafeLongArray(LongArray<V> laDelegate)
Construct a new SafeLongArray around the specified delegate.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method 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.SafeLongArray<V>
clone()
Make a clone of the LongArray.com.oracle.coherence.common.util.AutoLock<LongArray<V>>
getLock()
Return the lock used to protect this LongArray, with the unsafe delegate as itsresource
.-
Methods inherited from class com.tangosol.util.AbstractSafeLongArray
add, ceiling, ceilingIndex, clear, contains, exists, floor, floorIndex, get, getFirstIndex, getLastIndex, getSize, indexOf, indexOf, instantiateSafeIterator, isEmpty, iterator, iterator, lastIndexOf, lastIndexOf, remove, remove, reverseIterator, reverseIterator, set, toString
-
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
-
-
-
Method Detail
-
getLock
public com.oracle.coherence.common.util.AutoLock<LongArray<V>> getLock()
Return the lock used to protect this LongArray, with the unsafe delegate as itsresource
.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.
-
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 classAbstractSafeLongArray<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 classAbstractSafeLongArray<V>
- Returns:
- the lock sentry
-
-