Class NIOBuffersInterop
- java.lang.Object
-
- net.haesleinhuepf.clij.coremem.interop.NIOBuffersInterop
-
public class NIOBuffersInterop extends Object
NIO buffers interoperability- Author:
- royer
-
-
Constructor Summary
Constructors Constructor Description NIOBuffersInterop()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ArrayList<ByteBuffer>getByteBuffersForContiguousMemory(ContiguousMemoryInterface pContiguousMemory, long pPositionInBytes, long pLengthInBytes)This method creates a list of ByteBuffers that cover sequentially a given ContiguousMemory region.static OffHeapMemorygetContiguousMemoryFrom(Buffer pBuffer)Returns a contiguous buffer from a NIO buffer
-
-
-
Method Detail
-
getContiguousMemoryFrom
public static OffHeapMemory getContiguousMemoryFrom(Buffer pBuffer)
Returns a contiguous buffer from a NIO buffer- Parameters:
pBuffer- NIO buffer- Returns:
- contiguous memory
-
getByteBuffersForContiguousMemory
public static ArrayList<ByteBuffer> getByteBuffersForContiguousMemory(ContiguousMemoryInterface pContiguousMemory, long pPositionInBytes, long pLengthInBytes)
This method creates a list of ByteBuffers that cover sequentially a given ContiguousMemory region. This should only be used within the CoreMem classes. It's use is tricky... IMPORTANT: the bytebuffers returned do not hold references to the parent responsible for the memory lifecycle. This means that the references of these bytebuffers cannot escape the scope within which the ContiguousMemory reference is held. If the GC cleans up the ContiguousMemory and there is still a returned ByteBuffer 'alive', this will necessarily lead to a segmentation fault.- Parameters:
pContiguousMemory- contiguous memorypPositionInBytes- position in bytespLengthInBytes- length in bytes- Returns:
- array of NIO byte buffers corresponding to given contiguous memory region
-
-