public class MemoryAwareConcurrentReadMap extends Object
Modifier and Type | Class and Description |
---|---|
protected static class |
MemoryAwareConcurrentReadMap.BarrierLock
A Serializable class for barrier lock
|
Modifier and Type | Field and Description |
---|---|
protected MemoryAwareConcurrentReadMap.BarrierLock |
barrierLock
Lock used only for its memory effects.
|
protected int |
count
The total number of mappings in the hash table.
|
static int |
DEFAULT_INITIAL_CAPACITY
The default initial number of table slots for this table (32).
|
static float |
DEFAULT_LOAD_FACTOR
The default load factor for this table (1.0).
|
protected Object |
lastWrite
field written to only to guarantee lock ordering.
|
protected float |
loadFactor
The load factor for the hash table.
|
protected org.codehaus.groovy.runtime.metaclass.MemoryAwareConcurrentReadMap.Entry[] |
table
The hash table data.
|
protected int |
threshold
The table is rehashed when its size exceeds this threshold.
|
Constructor and Description |
---|
MemoryAwareConcurrentReadMap()
Constructs a new, empty map with a default initial capacity
and load factor.
|
MemoryAwareConcurrentReadMap(int initialCapacity)
Constructs a new, empty map with the specified initial
capacity and default load factor.
|
MemoryAwareConcurrentReadMap(int initialCapacity,
float loadFactor)
Constructs a new, empty map with the specified initial
capacity and the specified load factor.
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
Removes all mappings from this map.
|
protected boolean |
eq(Object x,
Object y)
Check for referential equality, null allowed
|
Object |
get(Object key)
Returns the value to which the specified key is mapped in this table.
|
protected org.codehaus.groovy.runtime.metaclass.MemoryAwareConcurrentReadMap.Entry[] |
getTableForReading()
Get ref to table; the reference and the cells it
accesses will be at least as fresh as from last
use of barrierLock
|
boolean |
isEmpty()
Returns true if this map contains no key-value mappings.
|
Object |
put(Object key,
Object value)
Maps the specified
key to the specified
value in this table. |
protected void |
recordModification(Object x)
Force a memory synchronization that will cause
all readers to see table.
|
protected void |
rehash()
Rehashes the contents of this map into a new table
with a larger capacity.
|
Object |
remove(Object key)
Removes the key (and its corresponding value) from this
table.
|
int |
size()
Returns the number of key-value mappings in this map.
|
protected Object |
sput(Object key,
Object value,
int hash)
Continuation of put(), called only when synch lock is
held and interference has been detected.
|
protected Object |
sremove(Object key,
int hash)
Continuation of remove(), called only when synch lock is
held and interference has been detected.
|
protected final MemoryAwareConcurrentReadMap.BarrierLock barrierLock
protected transient Object lastWrite
public static final int DEFAULT_INITIAL_CAPACITY
public static final float DEFAULT_LOAD_FACTOR
protected transient org.codehaus.groovy.runtime.metaclass.MemoryAwareConcurrentReadMap.Entry[] table
protected transient int count
protected int threshold
protected float loadFactor
public MemoryAwareConcurrentReadMap(int initialCapacity, float loadFactor)
initialCapacity
- the initial capacity
The actual initial capacity is rounded to the nearest power of two.loadFactor
- the load factor of the ConcurrentReaderHashMapIllegalArgumentException
- if the initial maximum number
of elements is less
than zero, or if the load factor is non-positive.public MemoryAwareConcurrentReadMap(int initialCapacity)
initialCapacity
- the initial capacity of the
ConcurrentReaderHashMap.IllegalArgumentException
- if the initial maximum number
of elements is less
than zero.public MemoryAwareConcurrentReadMap()
protected final void recordModification(Object x)
protected final org.codehaus.groovy.runtime.metaclass.MemoryAwareConcurrentReadMap.Entry[] getTableForReading()
public int size()
public boolean isEmpty()
public Object get(Object key)
key
- a key in the table.null
if the key is not mapped to any value in
this table.NullPointerException
- if the key is
null
.put(Object, Object)
public Object put(Object key, Object value)
key
to the specified
value
in this table. Neither the key nor the
value can be null
.
The value can be retrieved by calling the get
method
with a key that is equal to the original key.
key
- the table key.value
- the value.null
if it did not have one.NullPointerException
- if the key or value is
null
.get(Object)
protected Object sput(Object key, Object value, int hash)
protected void rehash()
public Object remove(Object key)
key
- the key that needs to be removed.null
if the key did not have a mapping.NullPointerException
- if the key is
null
.protected Object sremove(Object key, int hash)
public void clear()