DefaultBufferPool

class DefaultBufferPool(bufferSize: Int = DEFAULT_BUFFER_SIZE, capacity: Int = 1000, allocator: Allocator = DefaultAllocator) : DefaultPool<ChunkBuffer>

Constructors

Link copied to clipboard
constructor(bufferSize: Int = DEFAULT_BUFFER_SIZE, capacity: Int = 1000, allocator: Allocator = DefaultAllocator)

Properties

Link copied to clipboard
expect override val capacity: Int

Pool capacity.

Functions

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

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

Link copied to clipboard
open override fun close()

Does pool dispose

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

Link copied to clipboard
expect override fun recycle(instance: ChunkBuffer)

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

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