public interface AsyncPool<T> extends Closeable, AsyncCloseable
acquire()
and release(Object)
objects. All
activity of a pool task outcome is communicated through the returned CompletableFuture
.Modifier and Type | Method and Description |
---|---|
CompletableFuture<T> |
acquire()
Acquire an object from this
AsyncPool . |
void |
clear()
Clear the pool.
|
CompletableFuture<Void> |
clearAsync()
Clear the pool.
|
void |
close() |
CompletableFuture<Void> |
closeAsync()
Requests to close this object and releases any system resources associated with it.
|
CompletableFuture<Void> |
release(T object)
Release an object back to this
AsyncPool . |
CompletableFuture<T> acquire()
AsyncPool
. The returned CompletableFuture
is notified once the acquire is
successful and failed otherwise. Behavior upon acquiring objects from an exhausted pool depends on the actual pool
implementation whether requests are rejected immediately (exceptional completion with
NoSuchElementException
) or delayed after exceeding a particular timeout (
TimeoutException
).
It's required that an acquired object is always released to the pool again once the object is no longer in
use..CompletableFuture<Void> release(T object)
AsyncPool
. The returned CompletableFuture
is notified once the release is
successful and failed otherwise. When failed the object will automatically disposed.object
- the object to be released. The object must have been acquired from this pool.void clear()
CompletableFuture<Void> clearAsync()
void close()
close
in interface AutoCloseable
close
in interface Closeable
CompletableFuture<Void> closeAsync()
AsyncCloseable
Calls to this method return a CompletableFuture
that is notified with the outcome of the close request.
closeAsync
in interface AsyncCloseable
Copyright © 2023 lettuce.io. All rights reserved.