com.amazon.carbonado.util
Class AbstractPool<K,V,E extends Exception>

java.lang.Object
  extended by com.amazon.carbonado.util.AbstractPool<K,V,E>
Direct Known Subclasses:
SequenceValueProducerPool, StoragePool

public abstract class AbstractPool<K,V,E extends Exception>
extends Object

A concurrent pool of strongly referenced values mapped by key. Values are lazily created and pooled.

Since:
1.2
Author:
Brian S O'Neill

Constructor Summary
protected AbstractPool()
           
 
Method Summary
protected abstract  V create(K key)
          Return a new value instance.
 V get(K key)
          Returns a value for the given key, which is lazily created and pooled.
 V remove(Object key)
          Remove a value, returning the old value.
 Collection<V> values()
          Returns the pool values, which may be concurrently modified.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractPool

protected AbstractPool()
Method Detail

get

public V get(K key)
      throws E extends Exception
Returns a value for the given key, which is lazily created and pooled. If multiple threads are requesting upon the same key concurrently, at most one thread attempts to lazily create the value. The others wait for it to become available.

Throws:
E extends Exception

remove

public V remove(Object key)
Remove a value, returning the old value.


values

public Collection<V> values()
Returns the pool values, which may be concurrently modified.


create

protected abstract V create(K key)
                     throws E extends Exception
Return a new value instance.

Throws:
E extends Exception


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.