Pools.SimplePool

Added in 1.1.0

public class Pools.SimplePool<T extends Object> implements Pools.Pool

Known direct subclasses
Pools.SynchronizedPool

Synchronized pool of objects.


Simple (non-synchronized) pool of objects.

Parameters
<T extends Object>

The pooled type.

Summary

Public constructors

<T extends 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 <T extends Object> SimplePool(@IntRange(from = 1) int maxPoolSize)
Parameters
<T extends 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.