All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.otoroshi.wasm4s.scaladsl.opa.scala Maven / Gradle / Ivy

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
    }
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy