Interface LockedPool.Tracker<T>

Type Parameters:
T - the type of pooled objects
Enclosing class:
LockedPool<P>

public static interface LockedPool.Tracker<T>

A receiver of Pool events.

A simple implementations may just count acquire/release/remove pool events via, respectively, acquired(Pool, Entry), released(Pool, Entry) and removed(Pool, Entry), and make sure that the count is 0 when terminated(Pool, Collection) is called.

More advanced implementations may also obtain a stack trace at the time of the event to troubleshoot leaking of pooled entries.

  • Method Details

    • noTracker

      static <S> LockedPool.Tracker<S> noTracker()
      Type Parameters:
      S - the type of pooled objects
      Returns:
      a no-op implementation of Tracker
    • acquired

      default void acquired(Pool<T> pool, Pool.Entry<T> entry)

      Callback method invoked when an entry is acquired.

      Parameters:
      pool - the pool
      entry - the acquired entry
    • released

      default void released(Pool<T> pool, Pool.Entry<T> entry)

      Callback method invoked when an entry is released.

      Parameters:
      pool - the pool
      entry - the released entry
    • removed

      default void removed(Pool<T> pool, Pool.Entry<T> entry)

      Callback method invoked when an entry is removed.

      Parameters:
      pool - the pool
      entry - the removed entry
    • terminated

      default void terminated(Pool<T> pool, Collection<Pool.Entry<T>> entries)

      Callback method invoked when the Pool is terminated.

      Parameters:
      pool - the pool
      entries - the list of entries at termination