mirror of
https://github.com/curioustorvald/tsvm.git
synced 2026-06-06 13:38:30 +09:00
fix: out-of-main-thread VM disposal in VMEmu
This commit is contained in:
@@ -85,6 +85,8 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
|||||||
var vmRunners = HashMap<VmId, VMRunner>() // <VM's identifier, VMRunner>
|
var vmRunners = HashMap<VmId, VMRunner>() // <VM's identifier, VMRunner>
|
||||||
var coroutineJobs = HashMap<VmId, Thread>() // <VM's identifier, Job>
|
var coroutineJobs = HashMap<VmId, Thread>() // <VM's identifier, Job>
|
||||||
|
|
||||||
|
internal val whatToDoOnVmExceptionQueue = ArrayList<() -> Unit>()
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val APPDATADIR = TsvmEmulator.defaultDir
|
val APPDATADIR = TsvmEmulator.defaultDir
|
||||||
|
|
||||||
@@ -212,7 +214,7 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
|||||||
val gpu = ReferenceGraphicsAdapter("./assets", vm)
|
val gpu = ReferenceGraphicsAdapter("./assets", vm)
|
||||||
VMSetupBroker.initVMenv(vm, profiles[profileName]!!, profileName, gpu, vmRunners, coroutineJobs) {
|
VMSetupBroker.initVMenv(vm, profiles[profileName]!!, profileName, gpu, vmRunners, coroutineJobs) {
|
||||||
it.printStackTrace()
|
it.printStackTrace()
|
||||||
VMSetupBroker.killVMenv(vm, vmRunners, coroutineJobs)
|
whatToDoOnVmExceptionQueue.add { VMSetupBroker.killVMenv(vm, vmRunners, coroutineJobs) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,6 +271,15 @@ class VMEmuExecutable(val windowWidth: Int, val windowHeight: Int, var panelsX:
|
|||||||
renderGame(dt)
|
renderGame(dt)
|
||||||
|
|
||||||
watchdogs.forEach { (_, watchdog) -> watchdog.update(dt) }
|
watchdogs.forEach { (_, watchdog) -> watchdog.update(dt) }
|
||||||
|
|
||||||
|
|
||||||
|
val vmExceptionHandlers = whatToDoOnVmExceptionQueue.toList()
|
||||||
|
vmExceptionHandlers.forEach { it.invoke() }
|
||||||
|
synchronized(whatToDoOnVmExceptionQueue) {
|
||||||
|
vmExceptionHandlers.forEach {
|
||||||
|
whatToDoOnVmExceptionQueue.remove(it)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun reboot(profileName: String) {
|
private fun reboot(profileName: String) {
|
||||||
|
|||||||
Reference in New Issue
Block a user