Package org.jppf.utils.pooling
Class AbstractObjectPoolImpl<T>
java.lang.Object
org.jppf.utils.pooling.AbstractObjectPoolImpl<T>
- Type Parameters:
T-
- All Implemented Interfaces:
ObjectPool<T>
- Author:
- Laurent Cohen
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final AbstractObjectPoolImpl.LinkedData<T>The pool of objects. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract Tcreate()Create a new object for the pool.get()Get an object from the pool, or create it if the pool is empty.booleanisEmpty()Determine whether this pool is empty.voidRelease an object into this pool, and make it available.intsize()Get the number of objects in this pool.
-
Field Details
-
data
The pool of objects.
-
-
Constructor Details
-
AbstractObjectPoolImpl
public AbstractObjectPoolImpl()
-
-
Method Details
-
get
Description copied from interface:ObjectPoolGet an object from the pool, or create it if the pool is empty.- Specified by:
getin interfaceObjectPool<T>- Returns:
- a new Object of the type handled by this pool.
-
create
Create a new object for the pool.- Returns:
- an object that can be returned to the pool.
-
put
Description copied from interface:ObjectPoolRelease an object into this pool, and make it available.- Specified by:
putin interfaceObjectPool<T>- Parameters:
t- the object to release.
-
isEmpty
public boolean isEmpty()Description copied from interface:ObjectPoolDetermine whether this pool is empty.- Specified by:
isEmptyin interfaceObjectPool<T>- Returns:
trueif the pool is empty,falseotherwise.
-
size
public int size()Description copied from interface:ObjectPoolGet the number of objects in this pool. This is an optional operation, as it may not always be done in constant time.- Specified by:
sizein interfaceObjectPool<T>- Returns:
- the size of this pool, or -1 if this operation is not supported.
-