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>
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:
-
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
Modifier and TypeFieldDescriptionThe lock to hold during read and write operations.Fields inherited from class com.tangosol.util.AbstractSafeLongArray
NO_VALUE
-
Constructor Summary
ConstructorDescriptionConstruct a new SafeLongArray.SafeLongArray
(LongArray<V> laDelegate) Construct a new SafeLongArray around the specified delegate. -
Method Summary
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
-
Field Details
-
f_lock
The lock to hold during read and write operations.
-
-
Constructor Details
-
SafeLongArray
public SafeLongArray()Construct a new SafeLongArray. -
SafeLongArray
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
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
Description copied from interface:LongArray
Make a clone of the LongArray. The element values are not deep-cloned. -
acquireReadLock
Description copied from class:AbstractSafeLongArray
Acquire the read lock.- Specified by:
acquireReadLock
in classAbstractSafeLongArray<V>
- Returns:
- the lock sentry
-
acquireWriteLock
Description copied from class:AbstractSafeLongArray
Acquire the write lock.- Specified by:
acquireWriteLock
in classAbstractSafeLongArray<V>
- Returns:
- the lock sentry
-