Class PanamaWasiPollable

java.lang.Object
ai.tegmentum.wasmtime4j.panama.wasi.io.PanamaWasiPollable
All Implemented Interfaces:
ai.tegmentum.wasmtime4j.wasi.io.WasiPollable, AutoCloseable

public final class PanamaWasiPollable extends Object implements ai.tegmentum.wasmtime4j.wasi.io.WasiPollable, AutoCloseable
Panama FFI implementation of the WasiPollable interface.

This class provides access to WASI Preview 2 pollable operations through Panama Foreign Function API calls to the native Wasmtime library. Pollables are used for event notification and blocking operations on streams.

This implementation ensures defensive programming to prevent native resource leaks and JVM crashes.

Since:
1.0.0
  • Constructor Details

    • PanamaWasiPollable

      public PanamaWasiPollable(MemorySegment contextHandle, MemorySegment pollableHandle)
      Creates a new Panama WASI pollable with the given native handles.
      Parameters:
      contextHandle - the native context handle
      pollableHandle - the native pollable handle
      Throws:
      IllegalArgumentException - if either handle is null
  • Method Details

    • block

      public void block() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      block in interface ai.tegmentum.wasmtime4j.wasi.io.WasiPollable
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • ready

      public boolean ready() throws ai.tegmentum.wasmtime4j.exception.WasmException
      Specified by:
      ready in interface ai.tegmentum.wasmtime4j.wasi.io.WasiPollable
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getId

      public long getId()
    • getType

      public String getType()
    • isOwned

      public boolean isOwned()
    • isValid

      public boolean isValid()
    • getAvailableOperations

      public List<String> getAvailableOperations()
    • invoke

      public Object invoke(String operation, Object... parameters) throws ai.tegmentum.wasmtime4j.exception.WasmException
      Throws:
      ai.tegmentum.wasmtime4j.exception.WasmException
    • getLastAccessedAt

      public Optional<Instant> getLastAccessedAt()
    • getCreatedAt

      public Instant getCreatedAt()
    • getNativeHandle

      public MemorySegment getNativeHandle()
      Returns the native pollable handle.
      Returns:
      the native memory segment
    • isClosed

      public boolean isClosed()
      Checks if this pollable has been closed.
      Returns:
      true if closed
    • close

      public void close()
      Specified by:
      close in interface AutoCloseable