@file:OptIn(ExperimentalCoroutinesApi::class) package eu.friedcutlet.yokan.services.extensions.js import kotlinx.coroutines.CloseableCoroutineDispatcher import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.asCoroutineDispatcher import java.util.concurrent.Executors internal actual const val QuickJsMaxStackSizeBytes: Long = 8L * 1024L * 1024L // Daemon, so a runtime that is never disposed cannot keep the desktop JVM alive. internal actual fun quickJsDispatcher(stackBytes: Long): CloseableCoroutineDispatcher = Executors.newSingleThreadExecutor { task -> Thread(null, task, "quickjs", stackBytes).apply { isDaemon = true } } .asCoroutineDispatcher()