Added flag that allows MetaCall to disable threading, initialization, and destruction of MetaCall instances
@@ -28,7 +28,8 @@ object Caller {
private case class UniqueCall(call: Call, id: Int)
- private val callerThread = new Thread(() => {
+ private def callLoop() = {
+ if (System.getProperty("java.polyglot.name") != "metacall")
Bindings.instance.metacall_initialize()
while (!closed.get) {
@@ -42,8 +43,9 @@ object Caller {
} else ()
}
+ if (System.getProperty("java.polyglot.name") != "metacall")
Bindings.instance.metacall_destroy()
- })
+ }
private val closed = new AtomicBoolean(false)
private val callQueue = new LinkedBlockingQueue[UniqueCall]()
@@ -54,7 +56,12 @@ object Caller {
def loadFile(runtime: Runtime, filePath: String): Unit =
scriptsQueue.put(Script(filePath, runtime))
- def start(): Unit = callerThread.start()
+ def start(): Unit = {
+ if (System.getProperty("java.polyglot.name") != "metacall")
+ new Thread(() => callLoop()).start()
+ else
+ callLoop()
+ }
def destroy(): Unit = closed.set(true)
