mirror of
https://github.com/mamoe/mirai.git
synced 2025-01-05 23:50:08 +08:00
Use Mutex
than @Synchronized
This commit is contained in:
parent
df92607841
commit
0f1227d401
@ -11,6 +11,8 @@ package net.mamoe.mirai.internal.network.framework
|
||||
|
||||
import io.netty.channel.Channel
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
import kotlinx.coroutines.sync.withLock
|
||||
import net.mamoe.mirai.internal.QQAndroidBot
|
||||
import net.mamoe.mirai.internal.network.handler.NetworkHandler
|
||||
import net.mamoe.mirai.internal.network.handler.NetworkHandlerContext
|
||||
@ -35,9 +37,9 @@ internal open class TestNetworkHandler(
|
||||
val resumeDeferred = CompletableDeferred<Unit>()
|
||||
val resumeCount = AtomicInteger(0)
|
||||
val onResume get() = resumeDeferred.onJoin
|
||||
private val mutex = Mutex()
|
||||
|
||||
@Synchronized
|
||||
override suspend fun resumeConnection0() {
|
||||
override suspend fun resumeConnection0(): Unit = mutex.withLock {
|
||||
resumeCount.incrementAndGet()
|
||||
resumeDeferred.complete(Unit)
|
||||
when (this.correspondingState) {
|
||||
|
Loading…
Reference in New Issue
Block a user