Class OResourcePool<K,V>
java.lang.Object
com.orientechnologies.common.concur.resource.OResourcePool<K,V>
- Type Parameters:
K- Resource's KeyV- Resource Object
- Direct Known Subclasses:
OReentrantResourcePool
Generic non reentrant implementation about pool of resources. It pre-allocates a semaphore of
maxResources. Resources are lazily created by invoking the listener.
- Author:
- Luca Garulli (l.garulli--(at)--orientdb.com)
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AtomicIntegerprotected OResourcePoolListener<K,V> protected final Semaphoreprotected final Collection<V> -
Constructor Summary
ConstructorsConstructorDescriptionOResourcePool(int min, int max, OResourcePoolListener<K, V> listener) OResourcePool(int max, OResourcePoolListener<K, V> listener) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()intintintintgetResource(K key, long maxWaitMillis, Object... additionalArgs) intvoidbooleanreturnResource(V res)
-
Field Details
-
sem
-
resources
-
resourcesOut
-
unmodifiableresources
-
listener
-
created
-
-
Constructor Details
-
OResourcePool
-
OResourcePool
-
-
Method Details
-
getResource
public V getResource(K key, long maxWaitMillis, Object... additionalArgs) throws OAcquireTimeoutException - Throws:
OAcquireTimeoutException
-
getMaxResources
public int getMaxResources() -
getAvailableResources
public int getAvailableResources() -
getInPoolResources
public int getInPoolResources() -
returnResource
-
getResources
-
close
public void close() -
getAllResources
-
remove
-
getCreatedInstances
public int getCreatedInstances() -
getResourcesOutCount
public int getResourcesOutCount()
-