Class MemorySegmentBuffer
java.lang.Object
io.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
io.netty5.buffer.internal.AdaptableBuffer<MemorySegmentBuffer>
eu.cloudnetservice.driver.impl.network.netty.memory.MemorySegmentBuffer
- All Implemented Interfaces:
io.netty5.buffer.Buffer, io.netty5.buffer.BufferAccessor, io.netty5.buffer.BufferComponent, io.netty5.buffer.ComponentIterator<MemorySegmentBuffer>, io.netty5.buffer.ComponentIterator.Next, io.netty5.util.Resource<io.netty5.buffer.Buffer>, io.netty5.util.SafeCloseable, AutoCloseable
final class MemorySegmentBuffer
extends io.netty5.buffer.internal.AdaptableBuffer<MemorySegmentBuffer>
implements io.netty5.buffer.BufferComponent, io.netty5.buffer.ComponentIterator<MemorySegmentBuffer>, io.netty5.buffer.ComponentIterator.Next
Netty buffer implementation that is backed by a memory segment.
- Since:
- 4.0
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty5.buffer.ComponentIterator
io.netty5.buffer.ComponentIterator.Next -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate MemorySegmentprivate intprivate static final MemorySegmentprivate static final VarHandleprivate static final VarHandleprivate static final VarHandleprivate static final VarHandleprivate static final VarHandleprivate static final VarHandleprivate static final VarHandleprivate static final Supplier<UnsupportedOperationException> private intprivate MemorySegmentprivate static final io.netty5.buffer.internal.InternalBufferUtils.UncheckedLoadByteprivate intprivate MemorySegmentFields inherited from class io.netty5.buffer.internal.AdaptableBuffer
control -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivateMemorySegmentBuffer(@NonNull MemorySegmentBuffer parent, @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop) Constructs a buffer that represents a constant child of the given parent buffer.(package private)MemorySegmentBuffer(@NonNull MemorySegment baseSegment, @NonNull io.netty5.buffer.AllocatorControl control, @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop) Constructs a new memory segment buffer based on the given base segment.privateMemorySegmentBuffer(@NonNull MemorySegment baseSegment, @NonNull MemorySegment rwSegment, @NonNull io.netty5.buffer.AllocatorControl control, @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop) Constructs a new memory segment buffer based on the given memory segments. -
Method Summary
Modifier and TypeMethodDescriptionlongintbytesBefore(byte needle) intbytesBefore(@NonNull io.netty5.buffer.Buffer needle) intcapacity()compact()copy()copy(boolean readOnly) copy(int offset, int length) copy(int offset, int length, boolean readOnly) voidcopyInto(int srcPos, byte[] dest, int destPos, int length) voidvoidcopyInto(int srcPos, @NonNull ByteBuffer dest, int destPos, int length) intintintprotected @NonNull RuntimeExceptionprivate voidEnsures that this buffer is still accessible (not closed).private voidensureInSegmentBounds(int index, int size) Ensures that the visit of the givensizebytes starting at the given index happens within the bounds of the wrapped memory segment.private voidEnsures that this buffer is owned and can be used freely.private voidensureReadable(int index, int size) Ensures that at leastsizebytes were written into this buffer starting at the given index.ensureWritable(int size) ensureWritable(int size, int minimumGrowth, boolean allowCompaction) private voidEnsures that this buffer is writeable (not read-only).private voidensureWriteable(int index, int size, boolean canExpand) Ensures that at leastsizebytes can be written into this buffer starting at the given index.fill(byte value) first()<T extends io.netty5.buffer.BufferComponent & io.netty5.buffer.ComponentIterator.Next>
@NonNull io.netty5.buffer.ComponentIterator<T> bytegetByte(int roff) chargetChar(int roff) doublegetDouble(int roff) floatgetFloat(int roff) intgetInt(int roff) longgetLong(int roff) intgetMedium(int roff) shortgetShort(int roff) intgetUnsignedByte(int roff) longgetUnsignedInt(int roff) intgetUnsignedMedium(int roff) intgetUnsignedShort(int roff) booleanbooleanintimplicitCapacityLimit(int limit) booleanisDirect()layoutVarHandle(@NonNull ValueLayout layout) Creates aVarHandlethat can be used for unaligned, big endian access into a memory segment.protected void(package private) @NonNull MemorySegmentBufferAllocates a constant child which is similar to a read-only buffer but shares the memory region with this buffer.<N extends io.netty5.buffer.ComponentIterator.Next & io.netty5.buffer.BufferComponent>
Nnext()@NonNull io.netty5.buffer.ByteCursor@NonNull io.netty5.buffer.ByteCursoropenCursor(int fromOffset, int length) @NonNull io.netty5.buffer.ByteCursor@NonNull io.netty5.buffer.ByteCursoropenReverseCursor(int fromOffset, int length) protected @NonNull io.netty5.buffer.Owned<MemorySegmentBuffer> byte[]intintintlongbytereadByte()charreadChar()doubleintreaderOffset(int offset) floatintreadInt()longreadLong()intbooleanreadOnly()shortreadSplit(int length) intlongintintsetByte(int woff, byte value) setChar(int woff, char value) setDouble(int woff, double value) setFloat(int woff, float value) setInt(int woff, int value) setLong(int woff, long value) setMedium(int woff, int value) setShort(int woff, short value) setUnsignedByte(int woff, int value) setUnsignedInt(int woff, long value) setUnsignedMedium(int woff, int value) setUnsignedShort(int woff, int value) skipReadableBytes(int delta) skipWritableBytes(int delta) split()split(int splitOffset) toString()inttransferFrom(@NonNull FileChannel channel, long position, int length) inttransferFrom(@NonNull ReadableByteChannel channel, int length) inttransferTo(@NonNull FileChannel channel, long position, int length) inttransferTo(@NonNull WritableByteChannel channel, int length) (package private) @NonNull MemorySegmentUnsafe method to access the base segment used by this buffer.byte[]intintintlongwriteByte(byte value) writeBytes(byte[] source) writeBytes(byte[] source, int srcPos, int length) writeBytes(@NonNull ByteBuffer source) writeChar(char value) writeCharSequence(@NonNull CharSequence source, @NonNull Charset charset) writeDouble(double value) writeFloat(float value) writeInt(int value) writeLong(long value) writeMedium(int value) intwriterOffset(int offset) writeShort(short value) writeSplit(int length) writeUnsignedByte(int value) writeUnsignedInt(long value) writeUnsignedMedium(int value) writeUnsignedShort(int value) Methods inherited from class io.netty5.buffer.internal.AdaptableBuffer
equals, hashCode, touchMethods inherited from class io.netty5.buffer.internal.ResourceSupport
acquire, attachTrace, close, countBorrows, isAccessible, isOwned, notSendableException, send, unsafeGetDrop, unsafeSetDropMethods inherited from interface io.netty5.buffer.Buffer
readBytes, readBytes, readCharSequence, resetOffsets, toString, writeBytesMethods inherited from interface io.netty5.buffer.BufferAccessor
getBoolean, readBoolean, setBoolean, writeBooleanMethods inherited from interface io.netty5.buffer.ComponentIterator
firstReadable, firstWritableMethods inherited from interface io.netty5.buffer.ComponentIterator.Next
nextReadable, nextWritableMethods inherited from interface io.netty5.util.Resource
close, isAccessible, sendMethods inherited from interface io.netty5.util.SafeCloseable
close
-
Field Details
-
CLOSED_SEGMENT
-
LAYOUT_BYTE
-
LAYOUT_SHORT
-
LAYOUT_INT
-
LAYOUT_LONG
-
LAYOUT_FLOAT
-
LAYOUT_DOUBLE
-
LAYOUT_CHAR
-
UNCHECKED_LOAD_BYTE
private static final io.netty5.buffer.internal.InternalBufferUtils.UncheckedLoadByte UNCHECKED_LOAD_BYTE -
NO_BACKING_ARRAY
-
baseSegment
-
readSegment
-
writeSegment
-
readerOffset
private int readerOffset -
writerOffset
private int writerOffset -
capacityLimit
private int capacityLimit
-
-
Constructor Details
-
MemorySegmentBuffer
MemorySegmentBuffer(@NonNull @NonNull MemorySegment baseSegment, @NonNull @NonNull io.netty5.buffer.AllocatorControl control, @NonNull @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop) Constructs a new memory segment buffer based on the given base segment.- Parameters:
baseSegment- the base segment for the buffer, also used for reading and writing.control- the controller for the allocator that requested the allocation.drop- the drop which is associated with this buffer.- Throws:
NullPointerException- if the given base segment, control or drop is null.
-
MemorySegmentBuffer
private MemorySegmentBuffer(@NonNull @NonNull MemorySegment baseSegment, @NonNull @NonNull MemorySegment rwSegment, @NonNull @NonNull io.netty5.buffer.AllocatorControl control, @NonNull @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop) Constructs a new memory segment buffer based on the given memory segments.- Parameters:
baseSegment- the base segment for the buffer.rwSegment- the segment to use for reading and writing.control- the controller for the allocator that requested the allocation.drop- the drop which is associated with this buffer.- Throws:
NullPointerException- if the given base segment, rw-segment, control or drop is null.
-
MemorySegmentBuffer
private MemorySegmentBuffer(@NonNull @NonNull MemorySegmentBuffer parent, @NonNull @NonNull io.netty5.buffer.Drop<MemorySegmentBuffer> drop) Constructs a buffer that represents a constant child of the given parent buffer.- Parameters:
parent- the parent buffer of this constant child buffer.drop- the drop that is associated with this child buffer.- Throws:
NullPointerException- if the given parent buffer or drop is null.
-
-
Method Details
-
layoutVarHandle
Creates aVarHandlethat can be used for unaligned, big endian access into a memory segment.- Parameters:
layout- the layout to get the described var handle for.- Returns:
- a var handle for unaligned, big endian access into a memory segment.
- Throws:
NullPointerException- if the given value layout is null.
-
capacity
public int capacity()- Specified by:
capacityin interfaceio.netty5.buffer.Buffer
-
readerOffset
public int readerOffset()- Specified by:
readerOffsetin interfaceio.netty5.buffer.Buffer
-
skipReadableBytes
- Specified by:
skipReadableBytesin interfaceio.netty5.buffer.Buffer- Specified by:
skipReadableBytesin interfaceio.netty5.buffer.BufferComponent
-
readerOffset
- Specified by:
readerOffsetin interfaceio.netty5.buffer.Buffer
-
writerOffset
public int writerOffset()- Specified by:
writerOffsetin interfaceio.netty5.buffer.Buffer
-
skipWritableBytes
- Specified by:
skipWritableBytesin interfaceio.netty5.buffer.Buffer- Specified by:
skipWritableBytesin interfaceio.netty5.buffer.BufferComponent
-
writerOffset
- Specified by:
writerOffsetin interfaceio.netty5.buffer.Buffer
-
readableBytes
public int readableBytes()- Specified by:
readableBytesin interfaceio.netty5.buffer.Buffer- Specified by:
readableBytesin interfaceio.netty5.buffer.BufferComponent
-
writableBytes
public int writableBytes()- Specified by:
writableBytesin interfaceio.netty5.buffer.Buffer- Specified by:
writableBytesin interfaceio.netty5.buffer.BufferComponent
-
fill
- Specified by:
fillin interfaceio.netty5.buffer.Buffer
-
makeReadOnly
- Specified by:
makeReadOnlyin interfaceio.netty5.buffer.Buffer
-
readOnly
public boolean readOnly()- Specified by:
readOnlyin interfaceio.netty5.buffer.Buffer
-
isDirect
public boolean isDirect()- Specified by:
isDirectin interfaceio.netty5.buffer.Buffer
-
implicitCapacityLimit
- Specified by:
implicitCapacityLimitin interfaceio.netty5.buffer.Buffer
-
implicitCapacityLimit
public int implicitCapacityLimit()- Specified by:
implicitCapacityLimitin interfaceio.netty5.buffer.Buffer
-
copyInto
public void copyInto(int srcPos, byte[] dest, int destPos, int length) - Specified by:
copyIntoin interfaceio.netty5.buffer.Buffer
-
copyInto
- Specified by:
copyIntoin interfaceio.netty5.buffer.Buffer
-
copyInto
-
transferTo
- Specified by:
transferToin interfaceio.netty5.buffer.Buffer- Throws:
IOException
-
transferTo
public int transferTo(@NonNull @NonNull FileChannel channel, long position, int length) throws IOException - Specified by:
transferToin interfaceio.netty5.buffer.Buffer- Throws:
IOException
-
transferFrom
public int transferFrom(@NonNull @NonNull FileChannel channel, long position, int length) throws IOException - Specified by:
transferFromin interfaceio.netty5.buffer.Buffer- Throws:
IOException
-
transferFrom
public int transferFrom(@NonNull @NonNull ReadableByteChannel channel, int length) throws IOException - Specified by:
transferFromin interfaceio.netty5.buffer.Buffer- Throws:
IOException
-
writeCharSequence
@NonNull public @NonNull MemorySegmentBuffer writeCharSequence(@NonNull @NonNull CharSequence source, @NonNull @NonNull Charset charset) - Specified by:
writeCharSequencein interfaceio.netty5.buffer.Buffer
-
writeBytes
- Specified by:
writeBytesin interfaceio.netty5.buffer.Buffer
-
writeBytes
- Specified by:
writeBytesin interfaceio.netty5.buffer.Buffer
-
writeBytes
- Specified by:
writeBytesin interfaceio.netty5.buffer.Buffer
-
bytesBefore
public int bytesBefore(byte needle) - Specified by:
bytesBeforein interfaceio.netty5.buffer.Buffer
-
bytesBefore
-
openCursor
-
openCursor
-
openReverseCursor
-
openReverseCursor
-
ensureWritable
- Specified by:
ensureWritablein interfaceio.netty5.buffer.Buffer
-
ensureWritable
@NonNull public @NonNull MemorySegmentBuffer ensureWritable(int size, int minimumGrowth, boolean allowCompaction) - Specified by:
ensureWritablein interfaceio.netty5.buffer.Buffer
-
copy
- Specified by:
copyin interfaceio.netty5.buffer.Buffer
-
copy
- Specified by:
copyin interfaceio.netty5.buffer.Buffer
-
copy
- Specified by:
copyin interfaceio.netty5.buffer.Buffer
-
copy
- Specified by:
copyin interfaceio.netty5.buffer.Buffer
-
readSplit
- Specified by:
readSplitin interfaceio.netty5.buffer.Buffer
-
writeSplit
- Specified by:
writeSplitin interfaceio.netty5.buffer.Buffer
-
split
- Specified by:
splitin interfaceio.netty5.buffer.Buffer
-
split
- Specified by:
splitin interfaceio.netty5.buffer.Buffer
-
compact
- Specified by:
compactin interfaceio.netty5.buffer.Buffer
-
countComponents
public int countComponents()- Specified by:
countComponentsin interfaceio.netty5.buffer.Buffer
-
countReadableComponents
public int countReadableComponents()- Specified by:
countReadableComponentsin interfaceio.netty5.buffer.Buffer
-
countWritableComponents
public int countWritableComponents()- Specified by:
countWritableComponentsin interfaceio.netty5.buffer.Buffer
-
forEachComponent
-
readByte
public byte readByte()- Specified by:
readBytein interfaceio.netty5.buffer.BufferAccessor
-
getByte
public byte getByte(int roff) - Specified by:
getBytein interfaceio.netty5.buffer.BufferAccessor
-
readUnsignedByte
public int readUnsignedByte()- Specified by:
readUnsignedBytein interfaceio.netty5.buffer.BufferAccessor
-
getUnsignedByte
public int getUnsignedByte(int roff) - Specified by:
getUnsignedBytein interfaceio.netty5.buffer.BufferAccessor
-
writeByte
- Specified by:
writeBytein interfaceio.netty5.buffer.BufferAccessor
-
setByte
- Specified by:
setBytein interfaceio.netty5.buffer.BufferAccessor
-
writeUnsignedByte
- Specified by:
writeUnsignedBytein interfaceio.netty5.buffer.BufferAccessor
-
setUnsignedByte
- Specified by:
setUnsignedBytein interfaceio.netty5.buffer.BufferAccessor
-
readChar
public char readChar()- Specified by:
readCharin interfaceio.netty5.buffer.BufferAccessor
-
getChar
public char getChar(int roff) - Specified by:
getCharin interfaceio.netty5.buffer.BufferAccessor
-
writeChar
- Specified by:
writeCharin interfaceio.netty5.buffer.BufferAccessor
-
setChar
- Specified by:
setCharin interfaceio.netty5.buffer.BufferAccessor
-
readShort
public short readShort()- Specified by:
readShortin interfaceio.netty5.buffer.BufferAccessor
-
getShort
public short getShort(int roff) - Specified by:
getShortin interfaceio.netty5.buffer.BufferAccessor
-
readUnsignedShort
public int readUnsignedShort()- Specified by:
readUnsignedShortin interfaceio.netty5.buffer.BufferAccessor
-
getUnsignedShort
public int getUnsignedShort(int roff) - Specified by:
getUnsignedShortin interfaceio.netty5.buffer.BufferAccessor
-
writeShort
- Specified by:
writeShortin interfaceio.netty5.buffer.BufferAccessor
-
setShort
- Specified by:
setShortin interfaceio.netty5.buffer.BufferAccessor
-
writeUnsignedShort
- Specified by:
writeUnsignedShortin interfaceio.netty5.buffer.BufferAccessor
-
setUnsignedShort
- Specified by:
setUnsignedShortin interfaceio.netty5.buffer.BufferAccessor
-
readMedium
public int readMedium()- Specified by:
readMediumin interfaceio.netty5.buffer.BufferAccessor
-
getMedium
public int getMedium(int roff) - Specified by:
getMediumin interfaceio.netty5.buffer.BufferAccessor
-
readUnsignedMedium
public int readUnsignedMedium()- Specified by:
readUnsignedMediumin interfaceio.netty5.buffer.BufferAccessor
-
getUnsignedMedium
public int getUnsignedMedium(int roff) - Specified by:
getUnsignedMediumin interfaceio.netty5.buffer.BufferAccessor
-
writeMedium
- Specified by:
writeMediumin interfaceio.netty5.buffer.BufferAccessor
-
setMedium
- Specified by:
setMediumin interfaceio.netty5.buffer.BufferAccessor
-
writeUnsignedMedium
- Specified by:
writeUnsignedMediumin interfaceio.netty5.buffer.BufferAccessor
-
setUnsignedMedium
- Specified by:
setUnsignedMediumin interfaceio.netty5.buffer.BufferAccessor
-
readInt
public int readInt()- Specified by:
readIntin interfaceio.netty5.buffer.BufferAccessor
-
getInt
public int getInt(int roff) - Specified by:
getIntin interfaceio.netty5.buffer.BufferAccessor
-
readUnsignedInt
public long readUnsignedInt()- Specified by:
readUnsignedIntin interfaceio.netty5.buffer.BufferAccessor
-
getUnsignedInt
public long getUnsignedInt(int roff) - Specified by:
getUnsignedIntin interfaceio.netty5.buffer.BufferAccessor
-
writeInt
- Specified by:
writeIntin interfaceio.netty5.buffer.BufferAccessor
-
setInt
- Specified by:
setIntin interfaceio.netty5.buffer.BufferAccessor
-
writeUnsignedInt
- Specified by:
writeUnsignedIntin interfaceio.netty5.buffer.BufferAccessor
-
setUnsignedInt
- Specified by:
setUnsignedIntin interfaceio.netty5.buffer.BufferAccessor
-
readFloat
public float readFloat()- Specified by:
readFloatin interfaceio.netty5.buffer.BufferAccessor
-
getFloat
public float getFloat(int roff) - Specified by:
getFloatin interfaceio.netty5.buffer.BufferAccessor
-
writeFloat
- Specified by:
writeFloatin interfaceio.netty5.buffer.BufferAccessor
-
setFloat
- Specified by:
setFloatin interfaceio.netty5.buffer.BufferAccessor
-
readLong
public long readLong()- Specified by:
readLongin interfaceio.netty5.buffer.BufferAccessor
-
getLong
public long getLong(int roff) - Specified by:
getLongin interfaceio.netty5.buffer.BufferAccessor
-
writeLong
- Specified by:
writeLongin interfaceio.netty5.buffer.BufferAccessor
-
setLong
- Specified by:
setLongin interfaceio.netty5.buffer.BufferAccessor
-
readDouble
public double readDouble()- Specified by:
readDoublein interfaceio.netty5.buffer.BufferAccessor
-
getDouble
public double getDouble(int roff) - Specified by:
getDoublein interfaceio.netty5.buffer.BufferAccessor
-
writeDouble
- Specified by:
writeDoublein interfaceio.netty5.buffer.BufferAccessor
-
setDouble
- Specified by:
setDoublein interfaceio.netty5.buffer.BufferAccessor
-
hasReadableArray
public boolean hasReadableArray()- Specified by:
hasReadableArrayin interfaceio.netty5.buffer.BufferComponent
-
hasWritableArray
public boolean hasWritableArray()- Specified by:
hasWritableArrayin interfaceio.netty5.buffer.BufferComponent
-
readableArray
public byte[] readableArray()- Specified by:
readableArrayin interfaceio.netty5.buffer.BufferComponent
-
writableArray
public byte[] writableArray()- Specified by:
writableArrayin interfaceio.netty5.buffer.BufferComponent
-
readableArrayOffset
public int readableArrayOffset()- Specified by:
readableArrayOffsetin interfaceio.netty5.buffer.BufferComponent
-
writableArrayOffset
public int writableArrayOffset()- Specified by:
writableArrayOffsetin interfaceio.netty5.buffer.BufferComponent
-
readableArrayLength
public int readableArrayLength()- Specified by:
readableArrayLengthin interfaceio.netty5.buffer.BufferComponent
-
writableArrayLength
public int writableArrayLength()- Specified by:
writableArrayLengthin interfaceio.netty5.buffer.BufferComponent
-
baseNativeAddress
public long baseNativeAddress()- Specified by:
baseNativeAddressin interfaceio.netty5.buffer.BufferComponent
-
readableNativeAddress
public long readableNativeAddress()- Specified by:
readableNativeAddressin interfaceio.netty5.buffer.BufferComponent
-
writableNativeAddress
public long writableNativeAddress()- Specified by:
writableNativeAddressin interfaceio.netty5.buffer.BufferComponent
-
readableBuffer
- Specified by:
readableBufferin interfaceio.netty5.buffer.BufferComponent
-
writableBuffer
- Specified by:
writableBufferin interfaceio.netty5.buffer.BufferComponent
-
first
- Specified by:
firstin interfaceio.netty5.buffer.ComponentIterator<MemorySegmentBuffer>
-
next
@Nullable public <N extends io.netty5.buffer.ComponentIterator.Next & io.netty5.buffer.BufferComponent> N next()- Specified by:
nextin interfaceio.netty5.buffer.ComponentIterator.Next
-
createResourceClosedException
- Specified by:
createResourceClosedExceptionin classio.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
-
prepareSend
- Specified by:
prepareSendin classio.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
-
makeInaccessible
protected void makeInaccessible()- Overrides:
makeInaccessiblein classio.netty5.buffer.internal.ResourceSupport<io.netty5.buffer.Buffer, MemorySegmentBuffer>
-
toString
-
unsafeGetBase
Unsafe method to access the base segment used by this buffer. Should only be used by internal methods.- Returns:
- the base memory segment used by this buffer.
-
newConstChild
Allocates a constant child which is similar to a read-only buffer but shares the memory region with this buffer.- Returns:
- a constant child of this buffer.
- Throws:
IllegalStateException- if this buffer has already been freed.
-
ensureAccessible
private void ensureAccessible()Ensures that this buffer is still accessible (not closed).- Throws:
io.netty5.buffer.BufferClosedException- if this buffer is closed.
-
ensureOwned
private void ensureOwned()Ensures that this buffer is owned and can be used freely.- Throws:
IllegalStateException- if the buffer is not owned.
-
ensureWriteable
private void ensureWriteable()Ensures that this buffer is writeable (not read-only).- Throws:
io.netty5.buffer.BufferReadOnlyException- if this buffer is read-only.
-
ensureInSegmentBounds
private void ensureInSegmentBounds(int index, int size) Ensures that the visit of the givensizebytes starting at the given index happens within the bounds of the wrapped memory segment.- Parameters:
index- the index where the visit operation will start.size- the count of bytes that will be visited by the operation.- Throws:
io.netty5.buffer.BufferClosedException- if this buffer is closed.IndexOutOfBoundsException- if the given visit operation is beyond the size of the wrapped buffer.
-
ensureReadable
private void ensureReadable(int index, int size) Ensures that at leastsizebytes were written into this buffer starting at the given index.- Parameters:
index- the index to check from.size- the count of bytes to check for.- Throws:
io.netty5.buffer.BufferClosedException- if this buffer is closed.IndexOutOfBoundsException- if not enough bytes were written into the buffer to satisfy the read operation.
-
ensureWriteable
private void ensureWriteable(int index, int size, boolean canExpand) Ensures that at leastsizebytes can be written into this buffer starting at the given index. An attempt can be made to expand the buffer according to the needs ifcanExpandistrue.- Parameters:
index- the index to check from.size- the count of bytes that must be available.canExpand- if the buffer can be expanded to fit the requested byte count.- Throws:
io.netty5.buffer.BufferClosedException- if this buffer is closed.io.netty5.buffer.BufferReadOnlyException- if this buffer is read-only.IndexOutOfBoundsException- if not enough bytes are available in this buffer for the write operation.
-