[console] Let JLineInputDaemon use lock terminalExecuteLock; Try to fix \ #2322

This commit is contained in:
Karlatemp 2022-11-02 00:24:06 +08:00
parent 07000456cf
commit 9e7fd79225
No known key found for this signature in database
GPG Key ID: BA173CA2B9956C59

View File

@ -21,6 +21,7 @@ import org.jline.reader.impl.LineReaderImpl
import org.jline.utils.AttributedStringBuilder
import org.jline.utils.AttributedStyle
import java.util.*
import kotlin.concurrent.withLock
internal object JLineInputDaemon : Runnable {
lateinit var terminal0: MiraiConsoleImplementationTerminal
@ -166,8 +167,7 @@ internal object JLineInputDaemon : Runnable {
}
@Synchronized
internal fun suspendReader(canResumeByNewRequest: Boolean) {
internal fun suspendReader(canResumeByNewRequest: Boolean): Unit = terminalExecuteLock.withLock {
if (!lineReader.isReading) return
terminal.pause()
@ -177,8 +177,7 @@ internal object JLineInputDaemon : Runnable {
terminalDisplay.update(Collections.emptyList(), 0)
}
@Synchronized
internal fun tryResumeReader(byNewReq: Boolean) {
internal fun tryResumeReader(byNewReq: Boolean): Unit = terminalExecuteLock.withLock {
if (!pausedByDaemon) return
if (byNewReq && !canResumeByNewRequest) return