Interface ObjectPool<O>

Type Parameters:
O - The object type.
All Known Implementing Classes:
ConcurrentQueueObjectPool

public interface ObjectPool<O>
A pool of objects.
Author:
Christian Kohlschütter
  • Method Details

    • newThreadLocalPool

      static <O> ObjectPool<O> newThreadLocalPool(ObjectPool.ObjectSupplier<@NonNull O> supplier, ObjectPool.ObjectSanitizer<@NonNull O> sanitizer)
      Creates a new ObjectPool that is used within a single thread; this may or may not be implemented using ThreadLocal, however the behavior should be comparable.
      Type Parameters:
      O - The object type.
      Parameters:
      supplier - The object supplier.
      sanitizer - The object sanitizer.
      Returns:
      The object pool.
    • unpooledLease

      static <O> ObjectPool.Lease<O> unpooledLease(O obj)
      Returns a ObjectPool.Lease that is not backed by any object pool.
      Type Parameters:
      O - The object type.
      Parameters:
      obj - The object.
      Returns:
      The lease; closing/discarding has no effect.
    • take

      Takes an exclusive lease of an object from the pool. If no existing object is available from the pool, a new one may be provided.
      Returns:
      The object.