Poolable contained in the pool, and made
available via this pool tap, as determined by the
configured allocator.
Pool.
PoolTaps are not necessarily thread-safe, but pools, which extend PoolTap,
are always thread-safe.
stormpot.Pool
| Access | Constructor and Description |
|---|---|
| pack-priv |
| Modifier and Type | Method and Description |
|---|---|
| public final < The return type of the given function. R> Optional | Returns: anOptional of either the return value of applying the
given function to a claimed object, or empty if the timeout elapsed or
the function returned `null`.The timeout of the maximum permitted amount of time to wait
for an object to become available. A timeout with a value of zero or less
means that the call will do no waiting, preferring instead to return early
if no objects are available. timeout, Function<T, R> The function to apply to the claimed object, if any. The
function should avoid further claims, since having more than one object
claimed at a time per thread is inherently deadlock prone. function)Claim an object from the pool and apply the given function to it, returning the result and releasing the object back to the pool. |
| public abstract T | Returns: An object of the Poolable subtype T to which the exclusive rights have been claimed, or `null` if the timeout period elapsed before an object became available.The timeout of the maximum permitted time-slice to wait for
an object to become available. A timeout with a value of zero or less
means that the call will do no waiting, preferring instead to return early
if no objects are available. timeout)Claim the exclusive rights until released, to an object in the pool. |
| public final boolean | Returns: `true` if an object could be claimed within the given timeout and passed to the given consumer, or `false` otherwise.The timeout of the maximum permitted amount of time to wait
for an object to become available. A timeout with a value of zero or less
means that the call will do no waiting, preferring instead to return early
if no objects are available. timeout, Consumer<T> The consumer to pass the claimed object to, if any. The
consumer should avoid further claims, since having more than one object
claimed at a time per thread is inherently deadlock prone. consumer)Claim an object from the pool and supply it to the given consumer, and then release it back to the pool. |
| PoolTap | back to summary |
|---|---|
| pack-priv PoolTap() | |
| apply | back to summary |
|---|---|
| public final <R> Optional Claim an object from the pool and apply the given function to it, returning
the result and releasing the object back to the pool.
If an object cannot be claimed within the given timeout, then
| |
| claim | back to summary |
|---|---|
| public abstract T claim(Timeout timeout) throws PoolException, InterruptedException Claim the exclusive rights until released, to an object in the pool.
Possibly waiting up to the specified amount of time, as given by the
provided
| |
| supply | back to summary |
|---|---|
| public final boolean supply(Timeout timeout, Consumer<T> consumer) throws InterruptedException Claim an object from the pool and supply it to the given consumer, and then release it back to the pool. If an object cannot be claimed within the given timeout, then this method returns `false`. Otherwise, if an object was claimed and supplied to the consumer, the method returns `true`.
| |