From 66fb009627182b05bcf60c5c465000a66c68f8af Mon Sep 17 00:00:00 2001 From: Him188 Date: Fri, 10 Jan 2020 23:15:54 +0800 Subject: [PATCH] CoroutineNames --- .../network/TIMPCBotNetworkHandler.kt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt b/mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt index 6fb9de9a6..099a563e6 100644 --- a/mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt +++ b/mirai-core-timpc/src/commonMain/kotlin/net.mamoe.mirai.timpc/network/TIMPCBotNetworkHandler.kt @@ -113,7 +113,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor private var loginHandler: LoginHandler? = null - private suspend fun processReceive() { + private suspend inline fun processReceive() { while (channel.isOpen) { val input: ByteReadPacket = try { channel.read()// JVM: withContext(IO) @@ -173,8 +173,8 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor expectingTouchResponse = Job(supervisor) try { - launch { processReceive() } - launch { + launch(CoroutineName("Packet Receiver")) { processReceive() } + launch(CoroutineName("Timout checker")) { if (withTimeoutOrNull(bot.configuration.touchTimeoutMillis) { expectingTouchResponse!!.join() } == null) { loginResult.complete(LoginResult.TIMEOUT) } @@ -189,7 +189,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor private var expectingTouchResponse: CompletableJob? = null - private suspend fun handlePacket0( + private suspend inline fun handlePacket0( sequenceId: UShort, packet: TPacket, factory: PacketFactory @@ -439,7 +439,7 @@ internal class TIMPCBotNetworkHandler internal constructor(coroutineContext: Cor BotLoginSucceedEvent(bot).broadcast() val configuration = bot.configuration - heartbeatJob = this@TIMPCBotNetworkHandler.launch { + heartbeatJob = this@TIMPCBotNetworkHandler.launch(CoroutineName("Heartbeat Job")) { while (socket.isOpen) { delay(configuration.heartbeatPeriodMillis) with(bot) {