koblas

borrow

inline fun <T> Workspace?.borrow(size: Int, block: (DoubleArray) -> T): T(source)

Borrows a vector of size for block, allocating one when there is no workspace to lend it.

Handed back in a finally, so a routine whose kernels throw does not strand the borrow. A buffer never returned is one its pool can neither lend again nor reclaim, which pins that width for the life of the workspace.

The receiver is nullable because a workspace is optional everywhere it is taken, and Kotlin cannot carry both receivers under one name: nullability is not part of a JVM signature.