clj-artnet.impl.shell.buffers

Pools direct ByteBuffers for zero-allocation UDP I/O.

Provides a thread-safe, hot-path optimized regular buffer pool to minimize garbage collection pressure during high-throughput packet processing.

borrow!

(borrow! pool)

Borrows a buffer from the pool (blocking). Resets position/limit before returning. Throws ex-info if the pool is closed.

buffer-pool?

(buffer-pool? x)

Returns true if x is a BufferPool instance.

create-pool

(create-pool {:keys [count size direct?], :or {count 128, size 2048, direct? true}})

Creates ByteBuffer pool options.

Options: - :count -> Number of buffers to preallocate (default 128) - :size -> Buffer capacity in bytes (default 2048) - :direct? -> Use direct buffers (default true)

Returns a BufferPool which implements java.io.Closeable.

release!

(release! pool buf)

Returns a buffer to the pool. Safe to call multiple times or with nil. Clears buffer before return.