APIdia Launch Partner
Top Description Fields Constructors Methods
sun.nio.fs

pack-priv Class NativeBuffers

extends Object
Class Inheritance
Imports
jdk.internal.misc.TerminatingThreadLocal, .Unsafe

Factory for native buffers.

Field Summary

Modifier and TypeField and Description
private static final int
private static final TerminatingThreadLocal<NativeBuffer[]>
private static final Unsafe

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
pack-priv static NativeBuffer
allocNativeBuffer(int size)

Allocates a native buffer, of at least the given size, from the heap.

pack-priv static NativeBuffer
asNativeBuffer(byte[] cstr)

Copies a byte array and zero terminator into a native buffer, returning the buffer.

pack-priv static void
copyCStringToNativeBuffer(byte[] cstr, NativeBuffer buffer)

Copies a byte array and zero terminator into a given native buffer.

pack-priv static NativeBuffer
getNativeBuffer(int size)

Returns a native buffer, of at least the given size.

pack-priv static NativeBuffer
getNativeBufferFromCache(int size)

Returns a native buffer, of at least the given size, from the thread local cache.

pack-priv static void
releaseNativeBuffer(NativeBuffer buffer)

Releases the given buffer.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

TEMP_BUF_POOL_SIZEback to summary
private static final int TEMP_BUF_POOL_SIZE
threadLocalback to summary
private static final TerminatingThreadLocal<NativeBuffer[]> threadLocal
unsafeback to summary
private static final Unsafe unsafe

Constructor Detail

NativeBuffersback to summary
private NativeBuffers()

Method Detail

allocNativeBufferback to summary
pack-priv static NativeBuffer allocNativeBuffer(int size)

Allocates a native buffer, of at least the given size, from the heap.

asNativeBufferback to summary
pack-priv static NativeBuffer asNativeBuffer(byte[] cstr)

Copies a byte array and zero terminator into a native buffer, returning the buffer.

copyCStringToNativeBufferback to summary
pack-priv static void copyCStringToNativeBuffer(byte[] cstr, NativeBuffer buffer)

Copies a byte array and zero terminator into a given native buffer.

getNativeBufferback to summary
pack-priv static NativeBuffer getNativeBuffer(int size)

Returns a native buffer, of at least the given size. The native buffer is taken from the thread local cache if possible; otherwise it is allocated from the heap.

getNativeBufferFromCacheback to summary
pack-priv static NativeBuffer getNativeBufferFromCache(int size)

Returns a native buffer, of at least the given size, from the thread local cache.

releaseNativeBufferback to summary
pack-priv static void releaseNativeBuffer(NativeBuffer buffer)

Releases the given buffer. If there is space in the thread local cache then the buffer goes into the cache; otherwise the memory is deallocated.