mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-25 15:40:28 +08:00
Add CoroutineName for jobs
This commit is contained in:
parent
bbf2ead3f0
commit
7d51009361
@ -9,6 +9,7 @@
|
||||
|
||||
package net.mamoe.mirai.console.command
|
||||
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.cancelAndJoin
|
||||
import kotlinx.coroutines.launch
|
||||
@ -153,7 +154,7 @@ public object BuiltInCommands {
|
||||
sendMessage(
|
||||
"Login failed: ${throwable.localizedMessage ?: throwable.message ?: throwable.toString()}" +
|
||||
if (this is MessageEventContextAware<*>) {
|
||||
CommandManagerImpl.launch {
|
||||
CommandManagerImpl.launch(CoroutineName("stacktrace delayer from Login")) {
|
||||
fromEvent.nextMessageOrNull(60.secondsToMillis) { it.message.contentEquals("stacktrace") }
|
||||
}
|
||||
"\n 1 分钟内发送 stacktrace 以获取堆栈信息"
|
||||
|
@ -11,6 +11,7 @@
|
||||
|
||||
package net.mamoe.mirai.console.command
|
||||
|
||||
import kotlinx.coroutines.CoroutineName
|
||||
import kotlinx.coroutines.launch
|
||||
import net.mamoe.kjbb.JvmBlockingBridge
|
||||
import net.mamoe.mirai.Bot
|
||||
@ -89,7 +90,7 @@ public interface CommandSender {
|
||||
?: "${cause::class.simpleName.orEmpty()}: ${cause.message}"
|
||||
|
||||
sendMessage(message) // \n\n60 秒内发送 stacktrace 查看堆栈信息
|
||||
bot.launch {
|
||||
bot.launch(CoroutineName("stacktrace delayer from command")) {
|
||||
if (fromEvent.nextMessageOrNull(60_000) {
|
||||
it.message.contentEquals("stacktrace") || it.message.contentEquals("stack")
|
||||
} != null) {
|
||||
|
@ -13,6 +13,7 @@ package net.mamoe.mirai.console.data
|
||||
|
||||
import kotlinx.atomicfu.atomic
|
||||
import kotlinx.coroutines.*
|
||||
import net.mamoe.mirai.console.internal.command.qualifiedNameOrTip
|
||||
import net.mamoe.mirai.console.internal.plugin.updateWhen
|
||||
import net.mamoe.mirai.console.util.ConsoleExperimentalAPI
|
||||
import net.mamoe.mirai.console.util.ConsoleInternalAPI
|
||||
@ -53,7 +54,7 @@ public open class AutoSavePluginData private constructor(
|
||||
owner_.coroutineContext[Job]?.invokeOnCompletion { doSave() }
|
||||
|
||||
if (shouldPerformAutoSaveWheneverChanged()) {
|
||||
owner_.launch {
|
||||
owner_.launch(CoroutineName("AutoSavePluginData.timedAutoSave: ${this::class.qualifiedNameOrTip}")) {
|
||||
while (isActive) {
|
||||
delay(autoSaveIntervalMillis_.last) // 定时自动保存一次, 用于 kts 序列化的对象
|
||||
doSave()
|
||||
@ -99,7 +100,10 @@ public open class AutoSavePluginData private constructor(
|
||||
public final override fun onValueChanged(value: Value<*>) {
|
||||
debuggingLogger1.error { "onValueChanged: $value" }
|
||||
if (::owner_.isInitialized) {
|
||||
lastAutoSaveJob_ = owner_.launch(block = updaterBlock)
|
||||
lastAutoSaveJob_ = owner_.launch(
|
||||
block = updaterBlock,
|
||||
context = CoroutineName("AutoSavePluginData.passiveAutoSave: ${this::class.qualifiedNameOrTip}")
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user