io.otoroshi.wasm4s.scaladsl.opa.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wasm4s_2.12 Show documentation
Show all versions of wasm4s_2.12 Show documentation
Library to run wasm vm in a scala app
The newest version!
package io.otoroshi.wasm4s.scaladsl.opa
import io.otoroshi.wasm4s.scaladsl.WasmConfiguration
import org.extism.sdk.wasmotoroshi.LinearMemory
import java.util.concurrent.atomic.AtomicReference
object LinearMemories {
private val memories: AtomicReference[Seq[LinearMemory]] =
new AtomicReference[Seq[LinearMemory]](Seq.empty[LinearMemory])
def getMemories(config: WasmConfiguration): Array[LinearMemory] = {
if (config.opa) {
if (memories.get.isEmpty) {
memories.set(
io.otoroshi.wasm4s.impl.OPA.getLinearMemories()
)
}
memories.get().toArray
} else {
Array.empty
}
}
}