Module lettuce.core

Interface AsyncPool<T>

All Superinterfaces:
AsyncCloseable, AutoCloseable, Closeable
All Known Implementing Classes:
BoundedAsyncPool

public interface AsyncPool<T>
extends Closeable, AsyncCloseable
Interface declaring non-blocking object pool methods allowing to acquire() and release(Object) objects. All activity of a pool task outcome is communicated through the returned CompletableFuture.
Since:
5.1
Author:
Mark Paluch
  • Method Details

    • acquire

      CompletableFuture<T> acquire()
      Acquire an object from this 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..
    • release

      CompletableFuture<Void> release​(T object)
      Release an object back to this AsyncPool. The returned CompletableFuture 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 interface AutoCloseable
      Specified by:
      close in interface Closeable
    • 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 interface AsyncCloseable