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_collValuesThe values collection.protected booleanm_fStrictDetermines whether or not all of the Entry methods are protected; if set to true, then all Entry methods are protected.protected ReadWriteLockm_lockThe read/write lock for concurrency control.protected Lockm_lockExclusiveThe exclusive lock for performing read/write operations.protected Lockm_lockSharedThe shared lock for performing read operations.protected Map<K,V>m_mapDelegateThe Map to which this wrapper delegates.protected Set<Map.Entry<K,V>>m_setEntriesThe entry set.protected Set<K>m_setKeysThe key set.
-
Constructor Summary
Constructors Modifier Constructor Description protectedConcurrentWrapperMap()ConcurrentWrapperMap(Map<K,V> map)Create an ConcurrentWrapperMap which delegates to the specified Map.protectedConcurrentWrapperMap(Map<K,V> map, ReadWriteLock lock)Create an ConcurrentWrapperMap which delegates to the specified Map.protectedConcurrentWrapperMap(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 voidclear()Vcompute(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)VcomputeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)VcomputeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)booleancontainsKey(Object oKey)booleancontainsValue(Object oValue)Set<Map.Entry<K,V>>entrySet()booleanequals(Object oOther)voidforEach(BiConsumer<? super K,? super V> action)Vget(Object oKey)protected Map<K,V>getDelegate()Return the Map to which all operations should be delegated to.protected ReadWriteLockgetLock()Return the ReadWriteLock that is used to manage concurrent access and modifications to the underlying map.VgetOrDefault(Object key, V defaultValue)inthashCode()booleanisEmpty()Set<K>keySet()Vmerge(K key, V value, BiFunction<? super V,? super V,? extends V> remappingFunction)Vput(K oKey, V oValue)voidputAll(Map<? extends K,? extends V> map)VputIfAbsent(K key, V value)Vremove(Object oKey)booleanremove(Object key, Object value)Vreplace(K key, V value)booleanreplace(K key, V oldValue, V newValue)voidreplaceAll(BiFunction<? super K,? super V,? extends V> function)intsize()StringtoString()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:
containsKeyin interfaceMap<K,V>
-
containsValue
public boolean containsValue(Object oValue)
- Specified by:
containsValuein interfaceMap<K,V>
-
putIfAbsent
public V putIfAbsent(K key, V value)
- Specified by:
putIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
putIfAbsentin interfaceMap<K,V>
-
getOrDefault
public V getOrDefault(Object key, V defaultValue)
- Specified by:
getOrDefaultin interfaceConcurrentMap<K,V>- Specified by:
getOrDefaultin 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:
replaceAllin interfaceConcurrentMap<K,V>- Specified by:
replaceAllin interfaceMap<K,V>
-
computeIfAbsent
public V computeIfAbsent(K key, Function<? super K,? extends V> mappingFunction)
- Specified by:
computeIfAbsentin interfaceConcurrentMap<K,V>- Specified by:
computeIfAbsentin interfaceMap<K,V>
-
computeIfPresent
public V computeIfPresent(K key, BiFunction<? super K,? super V,? extends V> remappingFunction)
- Specified by:
computeIfPresentin interfaceConcurrentMap<K,V>- Specified by:
computeIfPresentin 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()
-
-