Android Dev Summit, October 23-24: two days of technical content, directly from the Android team. Sign-up for livestream updates.

Pool

interface Pool<T : Any!>
androidx.core.util.Pools.Pool

Interface for managing a pool of objects.

Summary

Public methods

abstract T?

abstract Boolean
release(@NonNull instance: T)

Release an instance to the pool.

Public methods

acquire

@Nullable abstract fun acquire(): T?
Return
T?: An instance from the pool if such, null otherwise.

release

abstract fun release(@NonNull instance: T): Boolean

Release an instance to the pool.

Parameters
instance T: The instance to release.
Return
Boolean: Whether the instance was put in the pool.
Exceptions
IllegalStateException If the instance is already in the pool.