Package com.tangosol.util
Class WrapperCollections.ConcurrentWrapperCollection<E>
- java.lang.Object
-
- com.tangosol.util.WrapperCollections.ConcurrentWrapperCollection<E>
-
- All Implemented Interfaces:
Iterable<E>
,Collection<E>
- Direct Known Subclasses:
WrapperCollections.ConcurrentWrapperSet
- Enclosing class:
- WrapperCollections
public static class WrapperCollections.ConcurrentWrapperCollection<E> extends Object implements Collection<E>
Collection implementation which uses a ReadWriteLock to manage concurrent access to an underlying Collection.- Since:
- Coherence 3.7
-
-
Field Summary
Fields Modifier and Type Field Description protected Collection<E>
m_colDelegate
The Collection to which this wrapper delegates.protected ReadWriteLock
m_lock
The read/write lock for concurrency control.protected Lock
m_lockExclusive
The exclusive lock for performing read/write operations.protected Lock
m_lockShared
The shared lock for performing read operations.
-
Constructor Summary
Constructors Modifier Constructor Description ConcurrentWrapperCollection(Collection<E> col)
Create an ConcurrentWrapperCollection which delegates to the specified Collection.protected
ConcurrentWrapperCollection(Collection<E> col, ReadWriteLock lock)
Create an ConcurrentWrapperCollection which delegates to the specified Collection.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
add(E o)
boolean
addAll(Collection<? extends E> c)
void
clear()
boolean
contains(Object o)
boolean
containsAll(Collection<?> c)
boolean
equals(Object oOther)
protected Collection<E>
getDelegate()
Return the Collection to which all operations should be delegated to.protected ReadWriteLock
getLock()
Return the ReadWriteLock that is used to manage concurrent access and modifications to the underlying map.int
hashCode()
boolean
isEmpty()
Iterator<E>
iterator()
boolean
remove(Object o)
boolean
removeAll(Collection<?> c)
boolean
retainAll(Collection<?> c)
int
size()
Object[]
toArray()
<T> T[]
toArray(T[] a)
String
toString()
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface java.util.Collection
parallelStream, removeIf, spliterator, stream, toArray
-
-
-
-
Field Detail
-
m_colDelegate
protected final Collection<E> m_colDelegate
The Collection to which this wrapper delegates.
-
m_lock
protected final ReadWriteLock m_lock
The read/write lock for concurrency control.
-
m_lockShared
protected final Lock m_lockShared
The shared lock for performing read operations.
-
m_lockExclusive
protected final Lock m_lockExclusive
The exclusive lock for performing read/write operations.
-
-
Constructor Detail
-
ConcurrentWrapperCollection
public ConcurrentWrapperCollection(Collection<E> col)
Create an ConcurrentWrapperCollection which delegates to the specified Collection.- Parameters:
col
- the Collection to delegate all calls to
-
ConcurrentWrapperCollection
protected ConcurrentWrapperCollection(Collection<E> col, ReadWriteLock lock)
Create an ConcurrentWrapperCollection which delegates to the specified Collection.- Parameters:
col
- the Collection to delegate all calls tolock
- a read/write lock for concurrency management
-
-
Method Detail
-
getDelegate
protected Collection<E> getDelegate()
Return the Collection to which all operations should be delegated to.- Returns:
- the wrapped Collection
-
getLock
protected ReadWriteLock getLock()
Return the ReadWriteLock that is used to manage concurrent access and modifications to the underlying map.- Returns:
- the ReadWriteLock
-
size
public int size()
- Specified by:
size
in interfaceCollection<E>
-
isEmpty
public boolean isEmpty()
- Specified by:
isEmpty
in interfaceCollection<E>
-
contains
public boolean contains(Object o)
- Specified by:
contains
in interfaceCollection<E>
-
toArray
public Object[] toArray()
- Specified by:
toArray
in interfaceCollection<E>
-
toArray
public <T> T[] toArray(T[] a)
- Specified by:
toArray
in interfaceCollection<E>
-
add
public boolean add(E o)
- Specified by:
add
in interfaceCollection<E>
-
remove
public boolean remove(Object o)
- Specified by:
remove
in interfaceCollection<E>
-
containsAll
public boolean containsAll(Collection<?> c)
- Specified by:
containsAll
in interfaceCollection<E>
-
addAll
public boolean addAll(Collection<? extends E> c)
- Specified by:
addAll
in interfaceCollection<E>
-
retainAll
public boolean retainAll(Collection<?> c)
- Specified by:
retainAll
in interfaceCollection<E>
-
removeAll
public boolean removeAll(Collection<?> c)
- Specified by:
removeAll
in interfaceCollection<E>
-
clear
public void clear()
- Specified by:
clear
in interfaceCollection<E>
-
equals
public boolean equals(Object oOther)
- Specified by:
equals
in interfaceCollection<E>
- Overrides:
equals
in classObject
-
hashCode
public int hashCode()
- Specified by:
hashCode
in interfaceCollection<E>
- Overrides:
hashCode
in classObject
-
-