A pool of objects, with support for multiplexing and several
optimized strategies plus an optional ThreadLocal cache
of the last released entry.
A Pool should be terminated when
it is no longer needed; once terminated, it cannot be used anymore.
| Modifier and Type | Class and Description |
|---|---|
| public static interface | |
| public static interface | |
| public static class |
| Modifier and Type | Method and Description |
|---|---|
| public Pool. | Returns: an entry from the pool or null if none is available.Acquires an entry from the pool. |
| public default Pool. | |
| public default int | |
| public default int | |
| public int | |
| public default int | |
| public default int | |
| public boolean | |
| public Pool. | Returns: a disabled entry that is contained in the pool, ornull
if the pool is terminated or if the pool cannot reserve an entryCreates a new disabled slot into the pool. |
| public int | |
| public Stream | |
| public Collection |
| acquire | back to summary |
|---|---|
| public Pool. Acquires an entry from the pool. Only enabled entries will be returned from this method
and their | |
| acquire | back to summary |
|---|---|
| public default Pool. Acquires an entry from the pool, reserving and creating a new entry if necessary. | |
| getIdleCount | back to summary |
|---|---|
public default int getIdleCount()
| |
| getInUseCount | back to summary |
|---|---|
public default int getInUseCount()
| |
| getMaxSize | back to summary |
|---|---|
public int getMaxSize()
| |
| getReservedCount | back to summary |
|---|---|
public default int getReservedCount()
| |
| getTerminatedCount | back to summary |
|---|---|
public default int getTerminatedCount()
| |
| isTerminated | back to summary |
|---|---|
public boolean isTerminated()
| |
| reserve | back to summary |
|---|---|
| public Pool. Creates a new disabled slot into the pool. The returned entry must ultimately have the | |
| size | back to summary |
|---|---|
public int size()
| |
| stream | back to summary |
|---|---|
| public Stream | |
| terminate | back to summary |
|---|---|
| public Collection Terminates this All the entries are marked as terminated and cannot be acquired nor released, but only removed. The returned list of all entries may be iterated to perform additional operations on the pooled objects. The pool cannot be used anymore after it is terminated.
| |
A Pool entry that holds metadata and a pooled object.
| Modifier and Type | Class and Description |
|---|---|
| public static class |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | |
| public E | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean |
| enable | back to summary |
|---|---|
| public boolean enable(E pooled, boolean acquire) Enables this, previously An entry returned from the The entry may be enabled and not acquired, in which case it is immediately available to be acquired, potentially by another thread; or it can be enabled and acquired atomically so that no other thread can acquire it, although the acquire may still fail if the pool has been terminated.
| |
| getPooled | back to summary |
|---|---|
public E getPooled()
| |
| isIdle | back to summary |
|---|---|
public boolean isIdle()
| |
| isInUse | back to summary |
|---|---|
public boolean isInUse()
| |
| isReserved | back to summary |
|---|---|
public boolean isReserved()
| |
| isTerminated | back to summary |
|---|---|
public boolean isTerminated()
| |
| release | back to summary |
|---|---|
| public boolean release() Releases this
| |
| remove | back to summary |
|---|---|
| public boolean remove() Removes this
| |
A wrapper for Entry instances.
| Modifier and Type | Method and Description |
|---|---|
| public boolean | enable(W
the pooled object for this pooled, boolean Entrywhether this acquire)Entry should be atomically enabled and acquiredImplements org. Enables this, previously |
| public W | |
| public Pool. | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean |
| wrapped | back to summary |
|---|---|
| private final Pool. | |
| Wrapper | back to summary |
|---|---|
| public Wrapper(Pool. | |
| enable | back to summary |
|---|---|
| public boolean enable(W pooled, boolean acquire) Implements org. Doc from org. Enables this, previously An entry returned from the The entry may be enabled and not acquired, in which case it is immediately available to be acquired, potentially by another thread; or it can be enabled and acquired atomically so that no other thread can acquire it, although the acquire may still fail if the pool has been terminated.
| |
| getPooled | back to summary |
|---|---|
| public W getPooled() Implements org.
| |
| getWrapped | back to summary |
|---|---|
| public Pool. | |
| isIdle | back to summary |
|---|---|
| public boolean isIdle() Implements org.
| |
| isInUse | back to summary |
|---|---|
| public boolean isInUse() Implements org.
| |
| isReserved | back to summary |
|---|---|
| public boolean isReserved() Implements org.
| |
| isTerminated | back to summary |
|---|---|
| public boolean isTerminated() Implements org.
| |
| release | back to summary |
|---|---|
| public boolean release() Implements org. Doc from org. Releases this
| |
| remove | back to summary |
|---|---|
| public boolean remove() Implements org. Doc from org. Removes this
| |
A factory for Pool instances.
| newPool | back to summary |
|---|---|
| public Pool | |
| wrap | back to summary |
|---|---|
| public default Pool Wraps, if necessary, the given pool.
| |
A wrapper for Pool instances.
| Modifier and Type | Method and Description |
|---|---|
| public Pool. | |
| public Pool. | acquire(Function<Pool.
a function to create the pooled value for a reserved entry. creatorOverrides default org. Acquires an entry from the pool, reserving and creating a new entry if necessary. |
| public int | |
| public int | |
| public int | |
| public int | |
| public int | |
| public Pool | |
| public boolean | |
| public Pool. | |
| public int | |
| public Stream | |
| public Collection |
| wrapped | back to summary |
|---|---|
| private final Pool<W> wrapped | |
| Wrapper | back to summary |
|---|---|
| public Wrapper(Pool<W> wrapped) | |
| acquire | back to summary |
|---|---|
| public Pool. Implements org. Doc from org. Acquires an entry from the pool. Only enabled entries will be returned from this method
and their | |
| acquire | back to summary |
|---|---|
| public Pool. Overrides default org. Doc from org. Acquires an entry from the pool, reserving and creating a new entry if necessary. | |
| getIdleCount | back to summary |
|---|---|
| public int getIdleCount() Overrides default org.
| |
| getInUseCount | back to summary |
|---|---|
| public int getInUseCount() Overrides default org.
| |
| getMaxSize | back to summary |
|---|---|
| public int getMaxSize() Implements org.
| |
| getReservedCount | back to summary |
|---|---|
| public int getReservedCount() Overrides default org.
| |
| getTerminatedCount | back to summary |
|---|---|
| public int getTerminatedCount() Overrides default org.
| |
| getWrapped | back to summary |
|---|---|
| public Pool | |
| isTerminated | back to summary |
|---|---|
| public boolean isTerminated() Implements org.
| |
| reserve | back to summary |
|---|---|
| public Pool. Implements org. Doc from org. Creates a new disabled slot into the pool. The returned entry must ultimately have the | |
| size | back to summary |
|---|---|
| public int size() Implements org.
| |
| stream | back to summary |
|---|---|
| public Stream Implements org. | |
| terminate | back to summary |
|---|---|
| public Collection Implements org. Doc from org. Terminates this All the entries are marked as terminated and cannot be acquired nor released, but only removed. The returned list of all entries may be iterated to perform additional operations on the pooled objects. The pool cannot be used anymore after it is terminated.
| |