Class Pools.SimplePool<T>

java.lang.Object
icyllis.modernui.util.Pools.SimplePool<T>
Type Parameters:
T - The pooled type.
All Implemented Interfaces:
Pools.Pool<T>
Direct Known Subclasses:
Pools.SynchronizedPool
Enclosing class:
Pools

public static class Pools.SimplePool<T> extends Object implements Pools.Pool<T>
Simple (non-synchronized) pool of objects.
  • Constructor Details

    • SimplePool

      public SimplePool(int maxPoolSize)
      Creates a new instance.
      Parameters:
      maxPoolSize - The max pool size.
      Throws:
      IllegalArgumentException - If the max pool size is less than zero.
  • Method Details

    • acquire

      @Nullable public T acquire()
      Specified by:
      acquire in interface Pools.Pool<T>
      Returns:
      An instance from the pool if such, null otherwise.
    • release

      public boolean release(@NonNull T instance)
      Description copied from interface: Pools.Pool
      Release an instance to the pool.
      Specified by:
      release in interface Pools.Pool<T>
      Parameters:
      instance - The instance to release.
      Returns:
      Whether the instance was put in the pool.