Package icyllis.modernui.util

# 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 Summary

  Constructors
  Constructor
  Description
  `SimplePool(int maxPoolSize)`
  Creates a new instance.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `T`
  `acquire()`
  `boolean`
  `release(T instance)`
  Release an instance to the pool.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## 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.