Package pcap.common.memory
Class Memories
java.lang.Object
pcap.common.memory.Memories
@Inclubating public final class Memories extends Object
- Author:
- Ardika Rommy Sanjaya
-
Constructor Summary
Constructors Constructor Description Memories()
-
Method Summary
Modifier and Type Method Description static MemoryAllocator
allocator()
Get default memory allocator.static MemoryAllocator
allocator(int poolSize, int maxPoolSize, int maxMemoryCapacity)
Get pooled memory allocator.static Memory
assemble(Memory... memories)
Assemble (combining) memory buffers (copying memories into single buffer).static MemoryAllocator
directAllocator()
Get direct memory allocator.static MemoryAllocator
directAllocator(int poolSize, int maxPoolSize, int maxMemoryCapacity)
Get pooled direct memory allocator.static MemoryAllocator
heapAllocator()
Get heap memory allocator.static MemoryAllocator
heapAllocator(int poolSize, int maxPoolSize, int maxMemoryCapacity)
Get pooled heap memory allocator.static Memory
wrap(byte[] bytes, boolean checking)
Wrap bytes array intoMemory
.static Memory
wrap(long memoryAddress, int size)
Wrap direct memory address intoMemory
object with bounds checking.static Memory
wrap(long memoryAddress, int size, boolean checking)
Wrap direct memory address intoMemory
object.static Memory
wrap(CharSequence hexStream)
Wrap hex string intoMemory
.static Memory
wrap(CharSequence hexStream, boolean checking, MemoryAllocator memoryAllocator)
Wrap hex string intoMemory
.static Memory
wrap(ByteBuffer buffer)
Wrap directByteBuffer
intoMemory
with bounds checking.static Memory
wrap(ByteBuffer buffer, boolean checking)
Wrap directByteBuffer
intoMemory
.
-
Constructor Details
-
Memories
public Memories()
-
-
Method Details
-
allocator
Get default memory allocator.- Returns:
- returns default memory allocator.
-
directAllocator
Get direct memory allocator.- Returns:
- returns direct memory allocator.
-
heapAllocator
Get heap memory allocator.- Returns:
- returns heap memory allocator.
-
allocator
Get pooled memory allocator.- Parameters:
poolSize
- pool size.maxPoolSize
- maximum pool size.maxMemoryCapacity
- memory capacity per buffer.- Returns:
- returns pooled
MemoryAllocator
.
-
directAllocator
public static MemoryAllocator directAllocator(int poolSize, int maxPoolSize, int maxMemoryCapacity)Get pooled direct memory allocator.- Parameters:
poolSize
- pool size.maxPoolSize
- maximum pool size.maxMemoryCapacity
- memory capacity per buffer.- Returns:
- returns pooled
MemoryAllocator
.
-
heapAllocator
Get pooled heap memory allocator.- Parameters:
poolSize
- pool size.maxPoolSize
- maximum pool size.maxMemoryCapacity
- memory capacity per buffer.- Returns:
- returns pooled
MemoryAllocator
.
-
wrap
Wrap direct memory address intoMemory
object with bounds checking.- Parameters:
memoryAddress
- memory address.size
- size of memory.- Returns:
- returns
Memory
. - Throws:
UnsupportedOperationException
- maybe unsafe is unavailable.
-
wrap
public static Memory wrap(long memoryAddress, int size, boolean checking) throws UnsupportedOperationExceptionWrap direct memory address intoMemory
object.- Parameters:
memoryAddress
- memory address.size
- size of memory.checking
- if true it will do bounds checking for every get/set method, false will not bounds checking.- Returns:
- returns
Memory
. - Throws:
UnsupportedOperationException
- maybe unsafe is unavailable.
-
wrap
Wrap directByteBuffer
intoMemory
with bounds checking.- Parameters:
buffer
- direct buffer.- Returns:
- returns
Memory
.
-
wrap
Wrap directByteBuffer
intoMemory
.- Parameters:
buffer
- direct buffer.checking
- if true it will do bounds checking for every get/set method, false will not bounds checking.- Returns:
- returns
Memory
.
-
wrap
Wrap hex string intoMemory
.- Parameters:
hexStream
- hex string.- Returns:
- returns
Memory
.
-
wrap
public static Memory wrap(CharSequence hexStream, boolean checking, MemoryAllocator memoryAllocator)Wrap hex string intoMemory
.- Parameters:
hexStream
- hex string.checking
- if true it will do bounds checking for every get/set method, false will not bounds checking.memoryAllocator
- memory allocator.- Returns:
- returns
Memory
. - Throws:
IllegalArgumentException
- invalid hex characters.
-
wrap
Wrap bytes array intoMemory
.- Parameters:
bytes
- raw bytes.checking
- if true it will do bounds checking for every get/set method, false will not bounds checking.- Returns:
- returns
Memory
.
-
assemble
Assemble (combining) memory buffers (copying memories into single buffer).- Parameters:
memories
- list of memory.- Returns:
- returns new direct
Memory
instance.
-