RuntimeException if none.
| Modifier and Type | Field and Description |
|---|---|
| private final Queue | unusedInstances
Instances that have been allocated but are unused. |
| private final Set | usedInstances
Instances that have been allocated. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public T | Returns: Either a new or a recycled object instance.Acquire on object instance of type T, either by reusing a previously recycled instance if possible, or if there are no currently-unused instances, by allocating a new instance. |
| public RecycleOnClose | Returns: Either a new or a recycled object instance.Acquire a Recyclable wrapper around an object instance, which can be used to recycle object instances at the end of a try-with-resources block. |
| public void | |
| public void | forceClose()
Force-close this |
| public abstract T | |
| public final void |
| unusedInstances | back to summary |
|---|---|
| private final Queue<T> unusedInstances Instances that have been allocated but are unused. | |
| usedInstances | back to summary |
|---|---|
| private final Set<T> usedInstances Instances that have been allocated. | |
| Recycler | back to summary |
|---|---|
| public Recycler() | |
| acquire | back to summary |
|---|---|
| public T acquire() throws SingletonMap:E Acquire on object instance of type T, either by reusing a previously recycled instance if possible, or if there are no currently-unused instances, by allocating a new instance.
| |
| acquireRecycleOnClose | back to summary |
|---|---|
| public RecycleOnClose Acquire a Recyclable wrapper around an object instance, which can be used to recycle object instances at the end of a try-with-resources block.
| |
| close | back to summary |
|---|---|
| public void close() Implements java. Free all unused instances. Calls
The
| |
| forceClose | back to summary |
|---|---|
| public void forceClose() Force-close this | |
| newInstance | back to summary |
|---|---|
| public abstract T newInstance() throws SingletonMap:E Create a new instance. This should either return a non-null instance of type T, or throw an exception of type E.
| |
| recycle | back to summary |
|---|---|
| public final void recycle(final T instance) Recycle an object for reuse by a subsequent call to
| |