Pools.SynchronizedPool

Added in 1.1.0

public class Pools.SynchronizedPool<T extends Object> extends Pools.SimplePool


Synchronized pool of objects.

Parameters
<T extends Object>

The pooled type.

Summary

Public constructors

<T extends Object> SynchronizedPool(int maxPoolSize)

Public methods

T
boolean
release(@NonNull T instance)

Release an instance to the pool.

Public constructors

SynchronizedPool

public <T extends Object> SynchronizedPool(int maxPoolSize)
Parameters
<T extends Object>

The pooled type.

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.