mirror of
https://github.com/TermoraDev/termora.git
synced 2026-01-16 02:12:58 +08:00
chore: coroutine SupervisorJob
This commit is contained in:
@@ -5,6 +5,7 @@ import app.termora.actions.DataProviders
|
|||||||
import app.termora.terminal.*
|
import app.termora.terminal.*
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
|
import kotlinx.coroutines.SupervisorJob
|
||||||
import kotlinx.coroutines.cancel
|
import kotlinx.coroutines.cancel
|
||||||
import kotlinx.coroutines.swing.Swing
|
import kotlinx.coroutines.swing.Swing
|
||||||
import java.beans.PropertyChangeEvent
|
import java.beans.PropertyChangeEvent
|
||||||
@@ -19,7 +20,7 @@ abstract class HostTerminalTab(
|
|||||||
val Host = DataKey(app.termora.Host::class)
|
val Host = DataKey(app.termora.Host::class)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val coroutineScope by lazy { CoroutineScope(Dispatchers.Swing) }
|
protected val coroutineScope by lazy { CoroutineScope(SupervisorJob() + Dispatchers.Swing) }
|
||||||
protected val terminalModel get() = terminal.getTerminalModel()
|
protected val terminalModel get() = terminal.getTerminalModel()
|
||||||
protected var unread = false
|
protected var unread = false
|
||||||
set(value) {
|
set(value) {
|
||||||
|
|||||||
@@ -89,7 +89,7 @@ class TerminalPanelFactory : Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val coroutineScope = CoroutineScope(Dispatchers.IO)
|
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ class SSHCopyIdDialog(
|
|||||||
terminalPanelFactory.createTerminalPanel(terminal, PtyConnectorDelegate())
|
terminalPanelFactory.createTerminalPanel(terminal, PtyConnectorDelegate())
|
||||||
.apply { enableFloatingToolbar = false }
|
.apply { enableFloatingToolbar = false }
|
||||||
}
|
}
|
||||||
private val coroutineScope = CoroutineScope(Job() + Dispatchers.IO)
|
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
init {
|
init {
|
||||||
size = Dimension(UIManager.getInt("Dialog.width") - 100, UIManager.getInt("Dialog.height") - 100)
|
size = Dimension(UIManager.getInt("Dialog.width") - 100, UIManager.getInt("Dialog.height") - 100)
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class TerminalBlink(terminal: Terminal) : Disposable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val coroutineScope by lazy { CoroutineScope(Dispatchers.IO) }
|
val coroutineScope by lazy { CoroutineScope(SupervisorJob() + Dispatchers.IO) }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 返回 true 表示可以显示某些内容 [TextStyle.blink]
|
* 返回 true 表示可以显示某些内容 [TextStyle.blink]
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ abstract class AutoRefreshPanel : JPanel(), Disposable {
|
|||||||
private val log = LoggerFactory.getLogger(AutoRefreshPanel::class.java)
|
private val log = LoggerFactory.getLogger(AutoRefreshPanel::class.java)
|
||||||
}
|
}
|
||||||
|
|
||||||
protected val coroutineScope = CoroutineScope(Dispatchers.IO)
|
protected val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
||||||
|
|
||||||
protected abstract suspend fun refresh(isFirst: Boolean)
|
protected abstract suspend fun refresh(isFirst: Boolean)
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,8 @@ class TerminalLoggerDataListener(private val terminal: Terminal) : DataListener
|
|||||||
action.removePropertyChangeListener(terminalLoggerActionPropertyChangeListener)
|
action.removePropertyChangeListener(terminalLoggerActionPropertyChangeListener)
|
||||||
action.addPropertyChangeListener(terminalLoggerActionPropertyChangeListener)
|
action.addPropertyChangeListener(terminalLoggerActionPropertyChangeListener)
|
||||||
|
|
||||||
val coroutineScope = this.coroutineScope ?: CoroutineScope(Dispatchers.IO).apply { coroutineScope = this }
|
val coroutineScope =
|
||||||
|
this.coroutineScope ?: CoroutineScope(SupervisorJob() + Dispatchers.IO).apply { coroutineScope = this }
|
||||||
val channel = this.channel ?: Channel<String>(Channel.UNLIMITED).apply { channel = this }
|
val channel = this.channel ?: Channel<String>(Channel.UNLIMITED).apply { channel = this }
|
||||||
|
|
||||||
coroutineScope.launch {
|
coroutineScope.launch {
|
||||||
|
|||||||
Reference in New Issue
Block a user