|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectjava.util.AbstractMap
org.norther.tammi.acorn.util.ConcurrentAbstractMap
org.norther.tammi.acorn.util.ConcurrentReadMap
public class ConcurrentReadMap
An implementation of the Map interface that supports
thread-safe concurrent reading and exclusive writing. The concurrent reader
policy provides a choice for reader oriented tasks that typically initialize
a map in one thread after construction and have several readers in multiple
threads using the map from there on. The ConcurrentWriteMap
class is another alternative for tasks needing concurrent writing as well.
Iterators and Enumerations return elements reflecting the state of the map at some point at or since the creation of the iterator/enumeration. They do not throw ConcurrentModificationException.
This implementation is based on the extended semantices of volatile specified
by JMM/JSR 133 that is available from jdk 1.5. A synchronized barrier based
implementation is provided by the ConcurrentLockMap class.
This class allows null to be used as a key or value.
Based on Doug Lea's ConcurrentReaderHashMap .
| Nested Class Summary |
|---|
| Nested classes/interfaces inherited from class org.norther.tammi.acorn.util.ConcurrentAbstractMap |
|---|
ConcurrentAbstractMap.Entry |
| Field Summary | |
|---|---|
protected static int |
DEFAULT_CAPACITY
The default capacity. |
protected static int |
MAXIMUM_CAPACITY
The maximum capacity. |
protected static int |
MINIMUM_CAPACITY
The minimum capacity. |
| Fields inherited from class org.norther.tammi.acorn.util.ConcurrentAbstractMap |
|---|
DEFAULT_LOAD_FACTOR |
| Constructor Summary | |
|---|---|
ConcurrentReadMap()
Constructs a new, empty map with a default capacity and load factor. |
|
ConcurrentReadMap(int capacity)
Constructs a new, empty map with the specified initial capacity and default load factor. |
|
ConcurrentReadMap(int capacity,
float factor)
Constructs a new, empty map with the specified initial capacity and the specified load factor. |
|
ConcurrentReadMap(Map map)
Constructs a new map with the same mappings as the given map. |
|
| Method Summary | |
|---|---|
protected int |
capacity(int capacity)
Returns the appropriate capacity for the expected maximum capacity. |
void |
clear()
|
Object |
clone()
|
boolean |
containsKey(Object key)
|
boolean |
containsValue(Object value)
|
protected ConcurrentAbstractMap.Entry |
getEntry(Object key)
Gets the internal entry mapped to the specified key. |
protected Object |
getInternal(Object key)
Gets the internal value mapped to the specified key. |
protected ConcurrentAbstractMap.Entry[] |
getReadTable()
Gets the internal read table. |
protected ConcurrentAbstractMap.Entry[] |
getWriteTable()
Gets the internal write table. |
boolean |
isEmpty()
|
void |
putAll(Map map)
|
protected Object |
putInternal(Object key,
Object value,
boolean r)
Puts the internal value mapped to the specified key. |
protected void |
recordWrite(Object x)
Forces a memory synchronization that will cause all readers to see the table. |
protected void |
rehash()
Rehashes the contents of this map into a new table with a larger capacity. |
protected Object |
removeInternal(Object key,
Object value)
Removes the internal mapping with the optional value. |
protected Object |
replaceInternal(Object key,
Object oldValue,
Object newValue)
Replaces the internal value mapped to the specified key with the optional value. |
protected void |
setWriteTable(ConcurrentAbstractMap.Entry[] tab)
Sets the internal write table. |
int |
size()
|
| Methods inherited from class org.norther.tammi.acorn.util.ConcurrentAbstractMap |
|---|
add, capacity, contains, elements, entrySet, get, hash, keys, keySet, put, putIfAbsent, remove, remove, replace, replace, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Field Detail |
|---|
protected static final int MAXIMUM_CAPACITY
protected static final int MINIMUM_CAPACITY
protected static final int DEFAULT_CAPACITY
| Constructor Detail |
|---|
public ConcurrentReadMap()
public ConcurrentReadMap(int capacity)
Note that the initial capacity will be rounded to the nearest power of two.
capacity - the initial capacity.
IllegalArgumentException - for negative values.
public ConcurrentReadMap(int capacity,
float factor)
Note that the initial capacity will be rounded to the nearest power of two.
capacity - the initial capacity.factor - the load factor of the map.
IllegalArgumentException - for negative values.public ConcurrentReadMap(Map map)
map - the map to copy.| Method Detail |
|---|
public Object clone()
clone in class ConcurrentAbstractMappublic int size()
size in interface Mapsize in class AbstractMappublic boolean isEmpty()
isEmpty in interface MapisEmpty in class AbstractMappublic boolean containsKey(Object key)
containsKey in interface MapcontainsKey in class AbstractMappublic boolean containsValue(Object value)
containsValue in interface MapcontainsValue in class AbstractMappublic void putAll(Map map)
putAll in interface MapputAll in class AbstractMappublic void clear()
clear in interface Mapclear in class AbstractMapprotected int capacity(int capacity)
ConcurrentAbstractMap
capacity in class ConcurrentAbstractMapcapacity - the desired capacity.
protected ConcurrentAbstractMap.Entry[] getReadTable()
ConcurrentAbstractMap
getReadTable in class ConcurrentAbstractMapprotected ConcurrentAbstractMap.Entry[] getWriteTable()
ConcurrentAbstractMap
getWriteTable in class ConcurrentAbstractMapprotected void setWriteTable(ConcurrentAbstractMap.Entry[] tab)
ConcurrentAbstractMap
setWriteTable in class ConcurrentAbstractMaptab - the write table.protected void recordWrite(Object x)
x - some object to be made visible.protected ConcurrentAbstractMap.Entry getEntry(Object key)
ConcurrentAbstractMap
getEntry in class ConcurrentAbstractMapkey - the key.
protected Object getInternal(Object key)
ConcurrentAbstractMap
getInternal in class ConcurrentAbstractMapkey - the key.
protected Object putInternal(Object key,
Object value,
boolean r)
ConcurrentAbstractMap
putInternal in class ConcurrentAbstractMapkey - the key.value - the value.r - if true, replace an existing mapping.
protected Object replaceInternal(Object key,
Object oldValue,
Object newValue)
ConcurrentAbstractMap
replaceInternal in class ConcurrentAbstractMapkey - the key.oldValue - the old value.newValue - the new value.
protected Object removeInternal(Object key,
Object value)
ConcurrentAbstractMap
removeInternal in class ConcurrentAbstractMapkey - the key.value - the value.
protected void rehash()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||