A Queue based implementation of Pool.
Entries are taken out of the pool when they are acquired
and they are added back when they are released which means
acquired and reserved entries do not account for the
maxSize calculation. This also means QueuedPool
is resistant to "release leaks".
This implementation does not support multiplexing.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private final int | |
| private final Queue | |
| private final AtomicInteger | |
| private final ReadWriteLock | |
| private boolean |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public Pool. | |
| public int | |
| public boolean | |
| private boolean | |
| public Pool. | |
| public int | |
| public Stream | |
| public Collection |
| maxSize | back to summary |
|---|---|
| private final int maxSize | |
| queue | back to summary |
|---|---|
| private final Queue<Pool. | |
| queueSize | back to summary |
|---|---|
| private final AtomicInteger queueSize | |
| rwLock | back to summary |
|---|---|
| private final ReadWriteLock rwLock | |
| terminated | back to summary |
|---|---|
| private boolean terminated | |
| QueuedPool | back to summary |
|---|---|
| public QueuedPool(int maxSize) | |
| 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 | |
| getMaxSize | back to summary |
|---|---|
| public int getMaxSize() Implements org.
| |
| isTerminated | back to summary |
|---|---|
| public boolean isTerminated() Implements org.
| |
| requeue | back to summary |
|---|---|
| private boolean requeue(Pool. | |
| 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.
| |
| Modifier and Type | Field and Description |
|---|---|
| private final QueuedPool | |
| private final AtomicMarkableReference |
| Access | Constructor and Description |
|---|---|
| private |
| Modifier and Type | Method and Description |
|---|---|
| pack-priv void | |
| public boolean | enable(P
the pooled object for this pooled, boolean Entrywhether this acquire)Entry should be atomically enabled and acquiredImplements org. Enables this, previously |
| public P | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean |
| pool | back to summary |
|---|---|
| private final QueuedPool<P> pool | |
| pooled | back to summary |
|---|---|
| private final AtomicMarkableReference<P> pooled | |
| QueuedEntry | back to summary |
|---|---|
| private QueuedEntry(QueuedPool<P> pool) | |
| acquire | back to summary |
|---|---|
| pack-priv void acquire() | |
| enable | back to summary |
|---|---|
| public boolean enable(P 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 P getPooled() Implements org.
| |
| 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
| |