Class PanamaPoolingAllocator

java.lang.Object
ai.tegmentum.wasmtime4j.panama.pool.PanamaPoolingAllocator
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.pool.PoolingAllocator, Closeable, AutoCloseable

public final class PanamaPoolingAllocator extends Object implements ai.tegmentum.wasmtime4j.pool.PoolingAllocator
Panama implementation of PoolingAllocator.

This implementation provides high-performance pooling allocation for WebAssembly execution by reusing pre-allocated memory pools for instances, stacks, and tables.

Since:
1.0.0
  • Constructor Details

    • PanamaPoolingAllocator

      public PanamaPoolingAllocator(ai.tegmentum.wasmtime4j.pool.PoolingAllocatorConfig config) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Creates a new PanamaPoolingAllocator with the specified configuration.
      Parameters:
      config - the allocator configuration
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException - if the allocator cannot be created
  • Method Details

    • getConfig

      public ai.tegmentum.wasmtime4j.pool.PoolingAllocatorConfig getConfig()
      Specified by:
      getConfig in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
    • allocateInstance

      public long allocateInstance() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      allocateInstance in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • reuseInstance

      public void reuseInstance(long instanceId) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      reuseInstance in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • releaseInstance

      public void releaseInstance(long instanceId) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      releaseInstance in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getStatistics

      public ai.tegmentum.wasmtime4j.pool.PoolStatistics getStatistics()
      Specified by:
      getStatistics in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
    • resetStatistics

      public void resetStatistics() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      resetStatistics in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • warmPools

      public void warmPools() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      warmPools in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • performMaintenance

      public void performMaintenance() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      performMaintenance in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • configureEngine

      public void configureEngine(ai.tegmentum.wasmtime4j.config.EngineConfig engineConfig) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      configureEngine in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getUptime

      public Duration getUptime()
      Specified by:
      getUptime in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.pool.PoolingAllocator
    • getNativeAllocator

      public MemorySegment getNativeAllocator()
      Gets the native allocator pointer for internal use.
      Returns:
      the native allocator pointer