Fix mattery network dispatcher preventing server from exiting sometimes

This commit is contained in:
DBotThePony 2023-07-30 11:19:39 +07:00
parent 7ce30ffd81
commit 49fc5b5eaf
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -166,14 +166,16 @@ abstract class MatteryNetworkChannel(val version: String, val name: String) {
internal fun onServerStarting() {
interrupt = false
check(thread == null) { "Already having network dispatcher thread, ServerStartingEvent was fired twice!" }
thread = Thread(this::run, "Overdrive That Matters Network Dispatcher").also { it.start() }
thread = Thread(this::run, "Overdrive That Matters Network Dispatcher").also { it.isDaemon = true; it.start() }
}
internal fun onServerStopping() {
LockSupport.unpark(thread)
interrupt = true
}
internal fun onServerStopped() {
LockSupport.unpark(thread)
interrupt = true
}
}