Class PanamaInstancePre

java.lang.Object
ai.tegmentum.wasmtime4j.panama.PanamaInstancePre
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.InstancePre, Closeable, AutoCloseable

public final class PanamaInstancePre extends Object implements ai.tegmentum.wasmtime4j.InstancePre
Panama FFI implementation of InstancePre.

This class wraps a native pre-instantiated module handle and provides fast instantiation capabilities. Pre-instantiation performs expensive setup work once, allowing subsequent instance creation to be significantly faster.

Since:
1.0.0
  • Constructor Details

    • PanamaInstancePre

      public PanamaInstancePre(MemorySegment nativeInstancePre, ai.tegmentum.wasmtime4j.Module module, ai.tegmentum.wasmtime4j.Engine engine)
      Creates a new PanamaInstancePre with the given native handle.
      Parameters:
      nativeInstancePre - the native InstancePre memory segment
      module - the module that was pre-instantiated
      engine - the engine used for pre-instantiation
      Throws:
      IllegalArgumentException - if nativeInstancePre is null or module/engine is null
  • Method Details

    • instantiate

      public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiate in interface ai.tegmentum.wasmtime4j.InstancePre
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • instantiate

      public ai.tegmentum.wasmtime4j.Instance instantiate(ai.tegmentum.wasmtime4j.Store store, ai.tegmentum.wasmtime4j.validation.ImportMap imports) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      instantiate in interface ai.tegmentum.wasmtime4j.InstancePre
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • instantiateAsync

      public CompletableFuture<ai.tegmentum.wasmtime4j.Instance> instantiateAsync(ai.tegmentum.wasmtime4j.Store store)
      Specified by:
      instantiateAsync in interface ai.tegmentum.wasmtime4j.InstancePre
    • getModule

      public ai.tegmentum.wasmtime4j.Module getModule()
      Specified by:
      getModule in interface ai.tegmentum.wasmtime4j.InstancePre
    • getEngine

      public ai.tegmentum.wasmtime4j.Engine getEngine()
      Specified by:
      getEngine in interface ai.tegmentum.wasmtime4j.InstancePre
    • isValid

      public boolean isValid()
      Specified by:
      isValid in interface ai.tegmentum.wasmtime4j.InstancePre
    • getInstanceCount

      public long getInstanceCount()
      Specified by:
      getInstanceCount in interface ai.tegmentum.wasmtime4j.InstancePre
    • getStatistics

      public ai.tegmentum.wasmtime4j.validation.PreInstantiationStatistics getStatistics()
      Specified by:
      getStatistics in interface ai.tegmentum.wasmtime4j.InstancePre
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface ai.tegmentum.wasmtime4j.InstancePre
    • getNativeInstancePre

      public MemorySegment getNativeInstancePre()
      Returns the native InstancePre memory segment.
      Returns:
      the native memory segment
    • toString

      public String toString()
      Overrides:
      toString in class Object