DefaultPool

expect abstract class DefaultPool<T : Any>(capacity: Int) : ObjectPool<T>

Default object pool implementation.

actual abstract class DefaultPool<T : Any>(val capacity: Int) : ObjectPool<T>
actual abstract class DefaultPool<T : Any>(val capacity: Int)

Inheritors

actual abstract class DefaultPool<T : Any>(val capacity: Int) : ObjectPool<T>

Constructors

Link copied to clipboard
expect constructor(capacity: Int)
actual constructor(capacity: Int)
actual constructor(capacity: Int)
actual constructor(capacity: Int)

Properties

Link copied to clipboard
Link copied to clipboard
expect override val capacity: Int

Pool capacity.

actual override val capacity: Int
actual val capacity: Int
actual override val capacity: Int
Link copied to clipboard
Link copied to clipboard
val inUsed: Int
Link copied to clipboard
Link copied to clipboard

Functions

Link copied to clipboard
expect override fun borrow(): T

borrow an instance. Pool can recycle an old instance or create a new one

actual override fun borrow(): T
actual fun borrow(): T
actual override fun borrow(): T
Link copied to clipboard
open override fun close()

Does pool dispose

open override fun close()
open override fun close()
Link copied to clipboard
expect override fun dispose()

Dispose the whole pool. None of borrowed objects could be used after the pool gets disposed otherwise it can result in undefined behaviour

actual override fun dispose()
actual fun dispose()
actual override fun dispose()
Link copied to clipboard
expect override fun recycle(instance: T)

Recycle an instance. Should be recycled what was borrowed before otherwise could fail

actual override fun recycle(instance: T)
actual fun recycle(instance: T)
actual override fun recycle(instance: T)
Link copied to clipboard
inline fun <T : Any, R> ObjectPool<T>.useBorrowed(block: (T) -> R): R

Borrows and instance of T from the pool, invokes block with it and finally recycles it

Link copied to clipboard
inline fun <T : Any, R> ObjectPool<T>.useInstance(block: (T) -> R): R

Borrows and instance of T from the pool, invokes block with it and finally recycles it