Class MemorySegmentMemoryManager
java.lang.Object
eu.cloudnetservice.driver.impl.network.netty.memory.MemorySegmentMemoryManager
- All Implemented Interfaces:
io.netty5.buffer.MemoryManager
@Internal
public final class MemorySegmentMemoryManager
extends Object
implements io.netty5.buffer.MemoryManager
Custom implementation of a netty memory manager based on memory segments. Direct buffers obtained from this
implementation are, in contrast to the netty implementation, not obtained from a shared arena. This allows for more
efficient freeing of the allocated memory segments.
- Since:
- 4.0
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NonNull io.netty5.buffer.BufferallocateConstChild(@NonNull io.netty5.buffer.Buffer readOnlyConstParent) @NonNull io.netty5.buffer.BufferallocateShared(@NonNull io.netty5.buffer.AllocatorControl allocatorControl, long size, @NonNull Function<io.netty5.buffer.Drop<io.netty5.buffer.Buffer>, io.netty5.buffer.Drop<io.netty5.buffer.Buffer>> dropDecorator, @NonNull io.netty5.buffer.AllocationType allocationType) voidclearMemory(@NonNull Object memory) private static @NonNull io.netty5.buffer.BufferconstructBuffer(@NonNull MemorySegment segment, @NonNull io.netty5.buffer.AllocatorControl allocatorControl, @NonNull Function<io.netty5.buffer.Drop<io.netty5.buffer.Buffer>, io.netty5.buffer.Drop<io.netty5.buffer.Buffer>> dropDecorator, @Nullable io.netty5.buffer.Drop<io.netty5.buffer.Buffer> segmentDrop) Constructs a new buffer instance for the given memory segment.@NonNull io.netty5.buffer.BufferrecoverMemory(@NonNull io.netty5.buffer.AllocatorControl allocatorControl, @NonNull Object recoverableMemory, @NonNull io.netty5.buffer.Drop<io.netty5.buffer.Buffer> drop) intsliceMemory(@NonNull Object memory, int offset, int length) unwrapRecoverableMemory(@NonNull io.netty5.buffer.Buffer buf)
-
Constructor Details
-
MemorySegmentMemoryManager
public MemorySegmentMemoryManager()
-
-
Method Details
-
constructBuffer
@NonNull private static @NonNull io.netty5.buffer.Buffer constructBuffer(@NonNull @NonNull MemorySegment segment, @NonNull @NonNull io.netty5.buffer.AllocatorControl allocatorControl, @NonNull @NonNull Function<io.netty5.buffer.Drop<io.netty5.buffer.Buffer>, io.netty5.buffer.Drop<io.netty5.buffer.Buffer>> dropDecorator, @Nullable @Nullable io.netty5.buffer.Drop<io.netty5.buffer.Buffer> segmentDrop) Constructs a new buffer instance for the given memory segment.- Parameters:
segment- the segment to use for the constructed buffer.allocatorControl- the controller for the allocator that requested the allocation.dropDecorator- function to decorate the drop that should be used by the constructed buffer.segmentDrop- the base drop to free the given segment, null in case there is nothing to drop.- Returns:
- a new buffer instance backed by the given memory segment.
- Throws:
NullPointerException- if the given segment, alloc control or drop decorator is null.
-
allocateConstChild
-
unwrapRecoverableMemory
-
recoverMemory
@NonNull public @NonNull io.netty5.buffer.Buffer recoverMemory(@NonNull @NonNull io.netty5.buffer.AllocatorControl allocatorControl, @NonNull @NonNull Object recoverableMemory, @NonNull @NonNull io.netty5.buffer.Drop<io.netty5.buffer.Buffer> drop) - Specified by:
recoverMemoryin interfaceio.netty5.buffer.MemoryManager
-
sliceMemory
-
clearMemory
-
sizeOf
-
implementationName
-