-
public interface Statics
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interfaceStatics.UncheckedLoadByteThis interface provides the fastest possible offsetted byte-access to a buffer.
-
Field Summary
Fields Modifier and Type Field Description static MethodHandleBB_PUT_OFFSETSstatic MethodHandleBB_SLICE_OFFSETSstatic CleanerCLEANERstatic intMAX_BUFFER_SIZEThe maximum buffer size we support is the maximum array length generally supported by JVMs, because on-heap buffers will be backed by byte-arrays.static LongAdderMEM_USAGE_NATIVEstatic Drop<Buffer>NO_OP_DROPstatic Statics.UncheckedLoadByteUNCHECKED_LOAD_BYTE_BUFFER
-
Method Summary
Static Methods Modifier and Type Method Description static <T> Tacquire(ResourceSupport<?,?> obj)static IllegalStateExceptionallocatorClosedException()static voidassertValidBufferSize(long size)Check the givensizeargument is a valid buffer size, or throw anIllegalArgumentException.static <E extends Throwable>
EattachTrace(ResourceSupport<?,?> obj, E throwable)static voidbbput(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)The ByteBuffer put-buffer-with-offset-and-length method is not available in Java 11.static ByteBufferbbslice(ByteBuffer buffer, int fromOffset, int length)The ByteBuffer slice-with-offset-and-length method is only available from Java 13 and onwards, but we need to support Java 11.static BufferClosedExceptionbufferIsClosed(Buffer buffer)static BufferReadOnlyExceptionbufferIsReadOnly(Buffer buffer)static intbytesBefore(Buffer haystack, Statics.UncheckedLoadByte hl, Buffer needle, Statics.UncheckedLoadByte nl)static voidcheckImplicitCapacity(int implicitCapacity, int currentCapacity)static voidcheckLength(int length)static <T,R>
Drop<R>convert(Drop<T> drop)static CharSequencecopyToCharSequence(Buffer source, int srcIdx, int length, Charset charset)static voidcopyToViaReverseLoop(Buffer src, int srcPos, Buffer dest, int destPos, int length)static intcountBorrows(ResourceSupport<?,?> obj)static booleanequals(Buffer a, int aStartIndex, Buffer b, int bStartIndex, int length)static booleanequals(Buffer bufferA, Buffer bufferB)static VarHandlefindVarHandle(MethodHandles.Lookup lookup, Class<?> recv, String name, Class<?> type)static MethodHandlegetByteBufferPutOffsetsMethodHandle()static MethodHandlegetByteBufferSliceOffsetsMethodHandle()static inthashCode(Buffer buffer)static booleanisOwned(ResourceSupport<?,?> obj)static longnativeAddressOfDirectByteBuffer(ByteBuffer byteBuffer)static longnativeAddressWithOffset(long address, int offset)Compute an offset into a native address.static CharSequencereadCharSequence(Buffer source, int length, Charset charset)static voidsetMemory(ByteBuffer buffer, int length, byte value)static Function<Drop<Buffer>,Drop<Buffer>>standardDrop(MemoryManager manager)static StringtoString(Buffer source, Charset charset)static ByteBuffertryGetWritableBufferFromReadableComponent(ReadableComponent component)static voidunsafeSetDrop(ResourceSupport<?,?> obj, Drop<?> replacement)static voidwriteCharSequence(CharSequence source, Buffer destination, Charset charset)
-
-
-
Field Detail
-
MEM_USAGE_NATIVE
static final LongAdder MEM_USAGE_NATIVE
-
CLEANER
static final Cleaner CLEANER
-
BB_SLICE_OFFSETS
static final MethodHandle BB_SLICE_OFFSETS
-
BB_PUT_OFFSETS
static final MethodHandle BB_PUT_OFFSETS
-
MAX_BUFFER_SIZE
static final int MAX_BUFFER_SIZE
The maximum buffer size we support is the maximum array length generally supported by JVMs, because on-heap buffers will be backed by byte-arrays.- See Also:
- Constant Field Values
-
UNCHECKED_LOAD_BYTE_BUFFER
static final Statics.UncheckedLoadByte UNCHECKED_LOAD_BYTE_BUFFER
-
-
Method Detail
-
getByteBufferSliceOffsetsMethodHandle
static MethodHandle getByteBufferSliceOffsetsMethodHandle()
-
getByteBufferPutOffsetsMethodHandle
static MethodHandle getByteBufferPutOffsetsMethodHandle()
-
findVarHandle
static VarHandle findVarHandle(MethodHandles.Lookup lookup, Class<?> recv, String name, Class<?> type)
-
assertValidBufferSize
static void assertValidBufferSize(long size)
Check the givensizeargument is a valid buffer size, or throw anIllegalArgumentException.- Parameters:
size- The size to check.- Throws:
IllegalArgumentException- if the size is not positive, or if the size is too big (over ~2 GB) for a buffer to accommodate.
-
checkImplicitCapacity
static void checkImplicitCapacity(int implicitCapacity, int currentCapacity)
-
checkLength
static void checkLength(int length)
-
copyToViaReverseLoop
static void copyToViaReverseLoop(Buffer src, int srcPos, Buffer dest, int destPos, int length)
-
tryGetWritableBufferFromReadableComponent
static ByteBuffer tryGetWritableBufferFromReadableComponent(ReadableComponent component)
-
bbslice
static ByteBuffer bbslice(ByteBuffer buffer, int fromOffset, int length)
The ByteBuffer slice-with-offset-and-length method is only available from Java 13 and onwards, but we need to support Java 11.
-
bbput
static void bbput(ByteBuffer dest, int destPos, ByteBuffer src, int srcPos, int length)
The ByteBuffer put-buffer-with-offset-and-length method is not available in Java 11.
-
setMemory
static void setMemory(ByteBuffer buffer, int length, byte value)
-
bufferIsClosed
static BufferClosedException bufferIsClosed(Buffer buffer)
-
bufferIsReadOnly
static BufferReadOnlyException bufferIsReadOnly(Buffer buffer)
-
allocatorClosedException
static IllegalStateException allocatorClosedException()
-
acquire
static <T> T acquire(ResourceSupport<?,?> obj)
-
isOwned
static boolean isOwned(ResourceSupport<?,?> obj)
-
countBorrows
static int countBorrows(ResourceSupport<?,?> obj)
-
attachTrace
static <E extends Throwable> E attachTrace(ResourceSupport<?,?> obj, E throwable)
-
unsafeSetDrop
static void unsafeSetDrop(ResourceSupport<?,?> obj, Drop<?> replacement)
-
readCharSequence
static CharSequence readCharSequence(Buffer source, int length, Charset charset)
-
copyToCharSequence
static CharSequence copyToCharSequence(Buffer source, int srcIdx, int length, Charset charset)
-
writeCharSequence
static void writeCharSequence(CharSequence source, Buffer destination, Charset charset)
-
hashCode
static int hashCode(Buffer buffer)
-
nativeAddressWithOffset
static long nativeAddressWithOffset(long address, int offset)Compute an offset into a native address. Zero is used as a marker for when a native address is not available, and an offset into a zero address will remain zero.- Parameters:
address- The native address, or zero if no native address is available.offset- The offset into the native address we wish to compute.- Returns:
- An offsetted native address, or zero if no native address was available.
-
nativeAddressOfDirectByteBuffer
static long nativeAddressOfDirectByteBuffer(ByteBuffer byteBuffer)
-
bytesBefore
static int bytesBefore(Buffer haystack, Statics.UncheckedLoadByte hl, Buffer needle, Statics.UncheckedLoadByte nl)
-
-