withBuffer

inline fun <R> withBuffer(size: Int, block: Buffer.() -> R): R

Invoke block function with a temporary Buffer instance of the specified size in bytes. The provided instance shouldn't be captured and used outside of the block otherwise an undefined behaviour may occur including crash and/or data corruption.


inline fun <R> withBuffer(pool: ObjectPool<Buffer>, block: Buffer.() -> R): R

Invoke block function with a temporary Buffer instance taken from the specified pool. Depending on the pool it may be safe or unsafe to capture and use the provided buffer outside of the block. Usually it is always recommended to NOT capture an instance outside.