public final class SharingObjectPool<T> extends Object implements RecyclingSupplier<T>
Modifier and Type | Class and Description |
---|---|
static class |
SharingObjectPool.SharedObject<T> |
RecyclingSupplier.Factory<T>
Constructor and Description |
---|
SharingObjectPool(RecyclingSupplier.Factory<T> factory,
int coreSize,
int maxSize) |
SharingObjectPool(RecyclingSupplier.Factory<T> factory,
int coreSize,
int maxSize,
boolean asyncValidate) |
Modifier and Type | Method and Description |
---|---|
void |
recycle(T object)
recycle object.
|
void |
recycle(T object,
Exception e)
return a object previously borrowed from the pool,
together with a optional exception in case one was encountered
while using the object.
|
String |
toString() |
boolean |
tryDispose(long timeoutMillis) |
T |
tryGet(long deadlineNanos) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
get, get, tryGet
close, dispose, dispose
public SharingObjectPool(RecyclingSupplier.Factory<T> factory, int coreSize, int maxSize) throws ObjectCreationException
ObjectCreationException
public SharingObjectPool(RecyclingSupplier.Factory<T> factory, int coreSize, int maxSize, boolean asyncValidate) throws ObjectCreationException
ObjectCreationException
@Nullable public T tryGet(long deadlineNanos) throws ObjectBorrowException, ObjectCreationException
tryGet
in interface RecyclingSupplier<T>
ObjectBorrowException
ObjectCreationException
public void recycle(T object, Exception e)
RecyclingSupplier
recycle
in interface RecyclingSupplier<T>
object
- - object to recycle.e
- - exception encountered while handling the object. this is useful for the recycle to validate/retire
objectpublic void recycle(T object)
RecyclingSupplier
recycle
in interface NonValidatingRecyclingSupplier<T>
recycle
in interface RecyclingSupplier<T>
object
- - object to recycle.public boolean tryDispose(long timeoutMillis) throws ObjectDisposeException, InterruptedException
tryDispose
in interface BlockingDisposable
ObjectDisposeException
InterruptedException
Copyright © 2018 SPF4J. All rights reserved.