public final class PinnedBuffer extends Object implements AutoCloseable
Buffer. For direct buffers, the address of the raw native memory encapsulated by the buffer is returned. For
array-based buffers, the array is pinned and the
address to the pinned Java memory is returned.
Not all kinds of buffers are supported. For example, when you create an array-based
ByteBuffer and wrap it as an IntBuffer, a
complicated nested structure is created that is not supported yet.| Modifier and Type | Method and Description |
|---|---|
<T extends org.graalvm.word.PointerBase> |
addressOf(int position)
Returns a pointer to the specified buffer element.
|
void |
close()
Releases the pin for the buffer.
|
Buffer |
getBuffer() |
boolean |
isOpen() |
static PinnedBuffer |
open(Buffer buffer)
Creates an open
PinnedBuffer for the provided Buffer. |
public static PinnedBuffer open(Buffer buffer)
PinnedBuffer for the provided Buffer.public Buffer getBuffer()
public boolean isOpen()
public <T extends org.graalvm.word.PointerBase> T addressOf(int position)
Buffer.position() of the buffer into account, but you can provide the
Buffer.position() of the buffer as the argument of this method.public void close()
PinnedBuffer.addressOf(int)
are no longer valid and must not be used anymore.close in interface AutoCloseable