DefaultPool
abstract expect class DefaultPool<T : Any> : ObjectPool<T>
Default object pool implementation.
Constructors
DefaultPool(capacity: Int) Default object pool implementation. |
Properties
val capacity: Int Pool capacity. |
Functions
fun borrow(): T borrow an instance. Pool can recycle an old instance or create a new one |
|
Clear instance’s state before reuse: reset pointers, counters and so on |
|
fun dispose(): Unit Dispose the whole pool. None of borrowed objects could be used after the pool gets disposed otherwise it can result in undefined behaviour |
|
Dispose instance and release it’s resources |
|
abstract fun produceInstance(): T Creates a new instance of T |
|
Recycle an instance. Should be recycled what was borrowed before otherwise could fail |
|
Validate instance of T. Could verify that the object has been borrowed from this pool |
Inherited Functions
open fun close(): Unit Does pool dispose |
Extension Functions
Borrows and instance of T from the pool, invokes block with it and finally recycles it |
|
Borrows and instance of T from the pool, invokes block with it and finally recycles it |
Inheritors
class |
|
class ByteBufferPool : DefaultPool<ByteBuffer> |
|
class |
|
class DirectByteBufferPool : DefaultPool<ByteBuffer> |