Class Memories

java.lang.Object
pcap.common.memory.Memories

@Inclubating
public final class Memories
extends Object
Author:
Ardika Rommy Sanjaya
  • Constructor Details

  • Method Details

    • allocator

      public static MemoryAllocator allocator()
      Get default memory allocator.
      Returns:
      returns default memory allocator.
    • directAllocator

      public static MemoryAllocator directAllocator()
      Get direct memory allocator.
      Returns:
      returns direct memory allocator.
    • heapAllocator

      public static MemoryAllocator heapAllocator()
      Get heap memory allocator.
      Returns:
      returns heap memory allocator.
    • allocator

      public static MemoryAllocator allocator​(int poolSize, int maxPoolSize, int maxMemoryCapacity)
      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

      public static MemoryAllocator heapAllocator​(int poolSize, int maxPoolSize, int maxMemoryCapacity)
      Get pooled heap memory allocator.
      Parameters:
      poolSize - pool size.
      maxPoolSize - maximum pool size.
      maxMemoryCapacity - memory capacity per buffer.
      Returns:
      returns pooled MemoryAllocator.
    • wrap

      public static Memory wrap​(long memoryAddress, int size) throws UnsupportedOperationException
      Wrap direct memory address into Memory 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 UnsupportedOperationException
      Wrap direct memory address into Memory 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

      public static Memory wrap​(ByteBuffer buffer)
      Wrap direct ByteBuffer into Memory with bounds checking.
      Parameters:
      buffer - direct buffer.
      Returns:
      returns Memory.
    • wrap

      public static Memory wrap​(ByteBuffer buffer, boolean checking)
      Wrap direct ByteBuffer into Memory.
      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

      public static Memory wrap​(CharSequence hexStream)
      Wrap hex string into Memory.
      Parameters:
      hexStream - hex string.
      Returns:
      returns Memory.
    • wrap

      public static Memory wrap​(CharSequence hexStream, boolean checking, MemoryAllocator memoryAllocator)
      Wrap hex string into Memory.
      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

      public static Memory wrap​(byte[] bytes, boolean checking)
      Wrap bytes array into Memory.
      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

      public static Memory assemble​(Memory... memories)
      Assemble (combining) memory buffers (copying memories into single buffer).
      Parameters:
      memories - list of memory.
      Returns:
      returns new direct Memory instance.