Class NativeMemorySegmentPool
java.lang.Object
org.episteme.nativ.util.NativeMemorySegmentPool
- All Implemented Interfaces:
AutoCloseable, MemorySegmentPool
A pool for native memory segments to reduce allocation overhead in tight loops.
This class is not thread-safe.
- Since:
- 1.1
- Author:
- Silvere Martin-Michiellot, Gemini AI (Google DeepMind)
-
Constructor Summary
ConstructorsConstructorDescriptionNativeMemorySegmentPool(Arena arena) Creates a new pool using a shared arena. -
Method Summary
Modifier and TypeMethodDescriptionacquire(long sizeBytes) Acquires a segment of at least the requested size.voidclose()intGets the number of segments currently in the pool.voidrelease(MemorySegment segment) Return a segment to the pool.
-
Constructor Details
-
NativeMemorySegmentPool
Creates a new pool using a shared arena.- Parameters:
arena- the arena to allocate from
-
-
Method Details
-
acquire
Acquires a segment of at least the requested size.- Specified by:
acquirein interfaceMemorySegmentPool- Parameters:
sizeBytes- requested size- Returns:
- a memory segment
-
release
Return a segment to the pool.- Specified by:
releasein interfaceMemorySegmentPool- Parameters:
segment- the segment to return
-
getPoolSize
public int getPoolSize()Description copied from interface:MemorySegmentPoolGets the number of segments currently in the pool.- Specified by:
getPoolSizein interfaceMemorySegmentPool- Returns:
- pool size
-
close
public void close()- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceMemorySegmentPool
-