Package com.tangosol.util
Class WrapperCollections.ConcurrentWrapperMap<K,V>
- java.lang.Object
-
- com.tangosol.util.WrapperCollections.ConcurrentWrapperMap<K,V>
-
- All Implemented Interfaces:
ConcurrentMap<K,V>
,Map<K,V>
- Enclosing class:
- WrapperCollections
public static class WrapperCollections.ConcurrentWrapperMap<K,V> extends Object implements ConcurrentMap<K,V>
Map implementation which uses a ReadWriteLock to manage concurrent access to an underlying Map.- Since:
- Coherence 3.7
-
-
Field Summary
Fields Modifier and Type Field Description protected Collection<V>
m_collValues
The values collection.protected boolean
m_fStrict
Determines whether or not all of the Entry methods are protected; if set to true, then all Entry methods are protected.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.protected Map<K,V>
m_mapDelegate
The Map to which this wrapper delegates.protected Set<Map.Entry<K,V>>
m_setEntries
The entry set.protected Set<K>
m_setKeys
The key set.
-
Constructor Summary
Constructors Modifier Constructor Description protected
ConcurrentWrapperMap()
ConcurrentWrapperMap(Map<K,V> map)
Create an ConcurrentWrapperMap which delegates to the specified Map.protected
ConcurrentWrapperMap(Map<K,V> map, ReadWriteLock lock)
Create an ConcurrentWrapperMap which delegates to the specified Map.protected
ConcurrentWrapperMap(Map<K,V> map, ReadWriteLock lock, boolean fStrict)
Create an ConcurrentWrapperMap which delegates to the specified Map.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
clear()
V
compute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
V
computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
V
computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
boolean
containsKey(Object oKey)
boolean
containsValue(Object oValue)
Set<Map.Entry<K,V>>
entrySet()
boolean
equals(Object oOther)
void
forEach(BiConsumer<? super K,? super V> action)
V
get(Object oKey)
protected Map<K,V>
getDelegate()
Return the Map 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.V
getOrDefault(Object key, V defaultValue)
int
hashCode()
boolean
isEmpty()
Set<K>
keySet()
V
merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
V
put(K oKey, V oValue)
void
putAll(Map<? extends K,? extends V> map)
V
putIfAbsent(K key, V value)
V
remove(Object oKey)
boolean
remove(Object key, Object value)
V
replace(K key, V value)
boolean
replace(K key, V oldValue, V newValue)
void
replaceAll(BiFunction<? super K,? super V,? extends V> function)
int
size()
String
toString()
Collection<V>
values()
-
-
-
Field Detail
-
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.
-
m_collValues
protected Collection<V> m_collValues
The values collection.
-
m_fStrict
protected final boolean m_fStrict
Determines whether or not all of the Entry methods are protected; if set to true, then all Entry methods are protected.
-
-
Constructor Detail
-
ConcurrentWrapperMap
protected ConcurrentWrapperMap()
-
ConcurrentWrapperMap
public ConcurrentWrapperMap(Map<K,V> map)
Create an ConcurrentWrapperMap which delegates to the specified Map.- Parameters:
map
- the Map to delegate all calls to
-
ConcurrentWrapperMap
protected ConcurrentWrapperMap(Map<K,V> map, ReadWriteLock lock)
Create an ConcurrentWrapperMap which delegates to the specified Map.- Parameters:
map
- the Map to delegate all calls tolock
- a read/write lock for concurrency management
-
ConcurrentWrapperMap
protected ConcurrentWrapperMap(Map<K,V> map, ReadWriteLock lock, boolean fStrict)
Create an ConcurrentWrapperMap which delegates to the specified Map.- Parameters:
map
- the Map to delegate all calls tolock
- a read/write lock for concurrency managementfStrict
- pass true to protect all Entry methods; false to protect only the setValue() method
-
-
Method Detail
-
getDelegate
protected Map<K,V> getDelegate()
Return the Map to which all operations should be delegated to.- Returns:
- the wrapped Map
-
getLock
protected ReadWriteLock getLock()
Return the ReadWriteLock that is used to manage concurrent access and modifications to the underlying map.- Returns:
- the ReadWriteLock
-
containsKey
public boolean containsKey(Object oKey)
- Specified by:
containsKey
in interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object oValue)
- Specified by:
containsValue
in interfaceMap<K,V>
-
putIfAbsent
public V putIfAbsent(K key, V value)
- Specified by:
putIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
putIfAbsent
in interfaceMap<K,V>
-
getOrDefault
public V getOrDefault(Object key, V defaultValue)
- Specified by:
getOrDefault
in interfaceConcurrentMap<K,V>
- Specified by:
getOrDefault
in interfaceMap<K,V>
-
forEach
public void forEach(BiConsumer<? super K,? super V> action)
-
replaceAll
public void replaceAll(BiFunction<? super K,? super V,? extends V> function)
- Specified by:
replaceAll
in interfaceConcurrentMap<K,V>
- Specified by:
replaceAll
in interfaceMap<K,V>
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
- Specified by:
computeIfAbsent
in interfaceConcurrentMap<K,V>
- Specified by:
computeIfAbsent
in interfaceMap<K,V>
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
- Specified by:
computeIfPresent
in interfaceConcurrentMap<K,V>
- Specified by:
computeIfPresent
in interfaceMap<K,V>
-
merge
public V merge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)
-
equals
public boolean equals(Object oOther)
-
hashCode
public int hashCode()
-
-