Pools.SimplePool

Added in 1.1.0

public class Pools.SimplePoolObject> implements Pools.Pool
Known direct subclasses
Pools.SynchronizedPool

Synchronized pool of objects.


Simple (non-synchronized) pool of objects.

Parameters
Object>

The pooled type.

Summary

Public constructors

Object> SimplePool(@IntRange(from = 1) int maxPoolSize)

Public methods

T
boolean
release(@NonNull T instance)

Release an instance to the pool.

Public constructors

SimplePool

public Object> SimplePool(@IntRange(from = 1) int maxPoolSize)
Parameters
Object>

The pooled type.

@IntRange(from = 1) int maxPoolSize

The maximum pool size

Public methods

acquire

public T acquire()
Returns
T

An instance from the pool if such, null otherwise.

release

public boolean release(@NonNull T instance)

Release an instance to the pool.

Parameters
@NonNull T instance

The instance to release.

Returns
boolean

Whether the instance was put in the pool.

Throws
kotlin.IllegalStateException

If the instance is already in the pool.