Class BufferRefImpl
java.lang.Object
express.mvp.roray.ffm.pool.BufferRefImpl
- All Implemented Interfaces:
BufferRef
-
Constructor Summary
ConstructorsConstructorDescriptionBufferRefImpl(MemorySegment segment, int poolIndex, IntConsumer releaseAction) Creates a new buffer reference for a pooled segment. -
Method Summary
Modifier and TypeMethodDescriptionlongaddress()Returns the raw native address of the segment.intlength()Returns the current length of valid data in the buffer (bytes).voidlength(int newLength) Sets the length of valid data in the buffer (bytes).intReturns the unique index of this buffer in its pool.voidrelease()Decrements the reference count (auto-returns to pool at 0).voidreset()Resets this buffer for reuse after acquisition from pool (refCount 0 -> 1).voidretain()Increments the reference count.segment()Returns the underlying FFM MemorySegment.toString()
-
Constructor Details
-
BufferRefImpl
Creates a new buffer reference for a pooled segment.- Parameters:
segment- the pooled memory segmentpoolIndex- the index used by the poolreleaseAction- callback invoked when the buffer returns to the pool
-
-
Method Details
-
reset
public void reset()Resets this buffer for reuse after acquisition from pool (refCount 0 -> 1). -
segment
Description copied from interface:BufferRefReturns the underlying FFM MemorySegment.Warning: Accessing this segment after
BufferRef.release()has reduced the refCount to 0 is undefined behavior. The segment may be reused by another thread or the underlying memory may be invalidated. -
address
-
poolIndex
-
length
-
length
-
retain
-
release
-
toString
-