Spring for Android

org.springframework.util
Class ConcurrentReferenceHashMap.Segment

java.lang.Object
  extended by java.util.concurrent.locks.ReentrantLock
      extended by org.springframework.util.ConcurrentReferenceHashMap.Segment
All Implemented Interfaces:
java.io.Serializable, java.util.concurrent.locks.Lock
Enclosing class:
ConcurrentReferenceHashMap<K,V>

protected final class ConcurrentReferenceHashMap.Segment
extends java.util.concurrent.locks.ReentrantLock

A single segment used to divide the map to allow better concurrent performance.

See Also:
Serialized Form

Constructor Summary
ConcurrentReferenceHashMap.Segment(int initialCapacity)
           
 
Method Summary
 void clear()
          Clear all items from this segment.
<T> T
doTask(int hash, java.lang.Object key, org.springframework.util.ConcurrentReferenceHashMap.Task<T> task)
          Apply an update operation to this segment.
 int getCount()
           
 ConcurrentReferenceHashMap.Reference<K,V> getReference(java.lang.Object key, int hash, ConcurrentReferenceHashMap.Restructure restructure)
           
 int getSize()
           
protected  void restructureIfNecessary(boolean allowResize)
          Restructure the underlying data structure when it becomes necessary.
 
Methods inherited from class java.util.concurrent.locks.ReentrantLock
getHoldCount, getOwner, getQueuedThreads, getQueueLength, getWaitingThreads, getWaitQueueLength, hasQueuedThread, hasQueuedThreads, hasWaiters, isFair, isHeldByCurrentThread, isLocked, lock, lockInterruptibly, newCondition, toString, tryLock, tryLock, unlock
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConcurrentReferenceHashMap.Segment

public ConcurrentReferenceHashMap.Segment(int initialCapacity)
Method Detail

getReference

public ConcurrentReferenceHashMap.Reference<K,V> getReference(java.lang.Object key,
                                                              int hash,
                                                              ConcurrentReferenceHashMap.Restructure restructure)

doTask

public <T> T doTask(int hash,
                    java.lang.Object key,
                    org.springframework.util.ConcurrentReferenceHashMap.Task<T> task)
Apply an update operation to this segment. The segment will be locked during the update.

Parameters:
hash - the hash of the key
key - the key
task - the update operation
Returns:
the result of the operation

clear

public void clear()
Clear all items from this segment.


restructureIfNecessary

protected final void restructureIfNecessary(boolean allowResize)
Restructure the underlying data structure when it becomes necessary. This method can increase the size of the references table as well as purge any references that have been garbage collected.

Parameters:
allowResize - if resizing is permitted

getSize

public final int getSize()
Returns:
the size of the current references array

getCount

public final int getCount()
Returns:
the total number of references in this segment

Spring for Android