pool
inline fun <Type> pool(initialCapacity: Int = 16, max: Int = Int.MAX_VALUE, crossinline discard: (Type) -> Unit = {}, crossinline provider: () -> Type): Pool<Type>
Return
a new Pool instance, creating the object with the passed provider.
Parameters
initialCapacity
initial size of the backing collection.
max
max amount stored in the pool. When exceeded, freed objects are no longer accepted.
discard
invoked each time an object is rejected or removed from the pool. This might happen if an object is freed with Pool.free or Pool.freeAll if the pool is full, or when Pool.clear is called. Optional, defaults to no operation. If the objects are Disposable, this lambda might be used to dispose of them.
provider
creates instances of the requested objects.