Class LockedPool<P>

java.lang.Object
org.eclipse.jetty.util.Pool.Wrapper<P>
org.eclipse.jetty.util.LockedPool<P>
Type Parameters:
P - the type of the pooled objects
All Implemented Interfaces:
Pool<P>

public class LockedPool<P> extends Pool.Wrapper<P>

A Pool.Wrapper that tracks the acquire/release/remove pool events.

The acquire/release/remove pool events are forwarded atomically to be handled by a LockedPool.Tracker implementation, so that the pool event and the handling of the event by the tracker are atomic.

  • Constructor Details

  • Method Details

    • reserve

      public Pool.Entry<P> reserve()
      Description copied from interface: Pool

      Creates a new disabled slot into the pool.

      The returned entry must ultimately have the Pool.Entry.enable(Object, boolean) method called or be removed via Pool.Entry.remove().

      Specified by:
      reserve in interface Pool<P>
      Overrides:
      reserve in class Pool.Wrapper<P>
      Returns:
      a disabled entry that is contained in the pool, or null if the pool is terminated or if the pool cannot reserve an entry
    • acquire

      public Pool.Entry<P> acquire()
      Description copied from interface: Pool

      Acquires an entry from the pool.

      Only enabled entries will be returned from this method and their Pool.Entry.enable(Object, boolean) method must not be called.

      Specified by:
      acquire in interface Pool<P>
      Overrides:
      acquire in class Pool.Wrapper<P>
      Returns:
      an entry from the pool or null if none is available.
    • acquire

      public Pool.Entry<P> acquire(Function<Pool.Entry<P>,P> creator)
      Description copied from interface: Pool

      Acquires an entry from the pool, reserving and creating a new entry if necessary.

      Specified by:
      acquire in interface Pool<P>
      Overrides:
      acquire in class Pool.Wrapper<P>
      Parameters:
      creator - a function to create the pooled value for a reserved entry.
      Returns:
      an entry from the pool or null if none is available.
    • isTerminated

      public boolean isTerminated()
      Specified by:
      isTerminated in interface Pool<P>
      Overrides:
      isTerminated in class Pool.Wrapper<P>
      Returns:
      whether this Pool has been terminated
      See Also:
    • terminate

      public Collection<Pool.Entry<P>> terminate()
      Description copied from interface: Pool

      Terminates this Pool.

      All the entries are marked as terminated and cannot be acquired nor released, but only removed.

      The returned list of all entries may be iterated to perform additional operations on the pooled objects.

      The pool cannot be used anymore after it is terminated.

      Specified by:
      terminate in interface Pool<P>
      Overrides:
      terminate in class Pool.Wrapper<P>
      Returns:
      a list of all entries
    • size

      public int size()
      Specified by:
      size in interface Pool<P>
      Overrides:
      size in class Pool.Wrapper<P>
      Returns:
      the current number of entries in this Pool
    • getMaxSize

      public int getMaxSize()
      Specified by:
      getMaxSize in interface Pool<P>
      Overrides:
      getMaxSize in class Pool.Wrapper<P>
      Returns:
      the maximum number of entries in this Pool
    • stream

      public Stream<Pool.Entry<P>> stream()
      Specified by:
      stream in interface Pool<P>
      Overrides:
      stream in class Pool.Wrapper<P>
      Returns:
      a Stream over the entries