org.norther.tammi.acorn.util
Class ConcurrentLockMap

java.lang.Object
  extended by java.util.AbstractMap
      extended by org.norther.tammi.acorn.util.ConcurrentAbstractMap
          extended by org.norther.tammi.acorn.util.ConcurrentReadMap
              extended by org.norther.tammi.acorn.util.ConcurrentLockMap
All Implemented Interfaces:
Serializable, Cloneable, ConcurrentMap, Map

public class ConcurrentLockMap
extends ConcurrentReadMap
implements Cloneable

A barrier based extension to the ConcurrentReadMap which works with jdk version prior to 1.5. In unit tests, it seems to perform slightly slower than the corresponding volatile implementation.

Based on Doug Lea's ConcurrentReaderHashMap .

Author:
Doug Lea, Ilkka Priha
See Also:
Serialized Form

Nested Class Summary
 
Nested classes/interfaces inherited from class org.norther.tammi.acorn.util.ConcurrentAbstractMap
ConcurrentAbstractMap.Entry
 
Field Summary
 
Fields inherited from class org.norther.tammi.acorn.util.ConcurrentReadMap
DEFAULT_CAPACITY, MAXIMUM_CAPACITY, MINIMUM_CAPACITY
 
Fields inherited from class org.norther.tammi.acorn.util.ConcurrentAbstractMap
DEFAULT_LOAD_FACTOR
 
Constructor Summary
ConcurrentLockMap()
          Constructs a new, empty map with a default capacity and load factor.
ConcurrentLockMap(int capacity)
          Constructs a new, empty map with the specified initial capacity and default load factor.
ConcurrentLockMap(int capacity, float factor)
          Constructs a new, empty map with the specified initial capacity and the specified load factor.
ConcurrentLockMap(Map map)
          Constructs a new map with the same mappings as the given map.
 
Method Summary
 Object clone()
           
protected  ConcurrentAbstractMap.Entry[] getReadTable()
          Gets the internal read table.
protected  ConcurrentAbstractMap.Entry[] getWriteTable()
          Gets the internal write table.
protected  void recordWrite(Object x)
          Forces a memory synchronization that will cause all readers to see the table.
protected  void setWriteTable(ConcurrentAbstractMap.Entry[] tab)
          Sets the internal write table.
 
Methods inherited from class org.norther.tammi.acorn.util.ConcurrentReadMap
capacity, clear, containsKey, containsValue, getEntry, getInternal, isEmpty, putAll, putInternal, rehash, removeInternal, replaceInternal, 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
 

Constructor Detail

ConcurrentLockMap

public ConcurrentLockMap()
Constructs a new, empty map with a default capacity and load factor.


ConcurrentLockMap

public ConcurrentLockMap(int capacity)
Constructs a new, empty map with the specified initial capacity and default load factor.

Note that the initial capacity will be rounded to the nearest power of two.

Parameters:
capacity - the initial capacity.
Throws:
IllegalArgumentException - for negative values.

ConcurrentLockMap

public ConcurrentLockMap(int capacity,
                         float factor)
Constructs a new, empty map with the specified initial capacity and the specified load factor.

Note that the initial capacity will be rounded to the nearest power of two.

Parameters:
capacity - the initial capacity.
factor - the load factor of the map.
Throws:
IllegalArgumentException - for negative values.

ConcurrentLockMap

public ConcurrentLockMap(Map map)
Constructs a new map with the same mappings as the given map. The map is created with a capacity of twice the number of mappings in the given map or minimum capacity (whichever is greater), and a default load factor.

Parameters:
map - the map to copy.
Method Detail

clone

public Object clone()
Overrides:
clone in class ConcurrentReadMap

getReadTable

protected ConcurrentAbstractMap.Entry[] getReadTable()
Description copied from class: ConcurrentAbstractMap
Gets the internal read table.

Overrides:
getReadTable in class ConcurrentReadMap
Returns:
the read table.

getWriteTable

protected ConcurrentAbstractMap.Entry[] getWriteTable()
Description copied from class: ConcurrentAbstractMap
Gets the internal write table.

Overrides:
getWriteTable in class ConcurrentReadMap
Returns:
the write table.

setWriteTable

protected void setWriteTable(ConcurrentAbstractMap.Entry[] tab)
Description copied from class: ConcurrentAbstractMap
Sets the internal write table.

Overrides:
setWriteTable in class ConcurrentReadMap
Parameters:
tab - the write table.

recordWrite

protected void recordWrite(Object x)
Description copied from class: ConcurrentReadMap
Forces a memory synchronization that will cause all readers to see the table. Call only when already holding main synch lock. The volatile implemention does nothing.

Overrides:
recordWrite in class ConcurrentReadMap
Parameters:
x - some object to be made visible.


Copyright © 2004 The Norther Organization. All rights reserved.