Package io.lettuce.core.support
Interface AsyncPool<T>
-
- All Superinterfaces:
AsyncCloseable
,AsyncCloseable
,AutoCloseable
,Closeable
- All Known Implementing Classes:
BoundedAsyncPool
public interface AsyncPool<T> extends Closeable, AsyncCloseable
Interface declaring non-blocking object pool methods allowing toacquire()
andrelease(Object)
objects. All activity of a pool task outcome is communicated through the returnedCompletableFuture
.- Since:
- 5.1
- Author:
- Mark Paluch
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description CompletableFuture<T>
acquire()
Acquire an object from thisAsyncPool
.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 thisAsyncPool
.
-
-
-
Method Detail
-
acquire
CompletableFuture<T> acquire()
Acquire an object from thisAsyncPool
. The returnedCompletableFuture
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 withNoSuchElementException
) 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..
-
release
CompletableFuture<Void> release(T object)
Release an object back to thisAsyncPool
. The returnedCompletableFuture
is notified once the release is successful and failed otherwise. When failed the object will automatically disposed.- Parameters:
object
- the object to be released. The object must have been acquired from this pool.
-
clear
void clear()
Clear the pool.
-
clearAsync
CompletableFuture<Void> clearAsync()
Clear the pool.
-
close
void close()
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
closeAsync
CompletableFuture<Void> closeAsync()
Description copied from interface:AsyncCloseable
Requests to close this object and releases any system resources associated with it. If the object is already closed then invoking this method has no effect.Calls to this method return a
CompletableFuture
that is notified with the outcome of the close request.- Specified by:
closeAsync
in interfaceAsyncCloseable
- Specified by:
closeAsync
in interfaceAsyncCloseable
-
-