mirror of
https://github.com/mamoe/mirai.git
synced 2025-02-03 13:12:25 +08:00
Enhance performance
This commit is contained in:
parent
0981122401
commit
0662dc839f
@ -129,16 +129,15 @@ internal object EventListenerManger {
|
|||||||
private val registriesMutex = Mutex()
|
private val registriesMutex = Mutex()
|
||||||
|
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
internal suspend fun <E : Subscribable> get(clazz: KClass<out E>): EventListeners<E> = registriesMutex.withLock {
|
internal suspend fun <E : Subscribable> get(clazz: KClass<out E>): EventListeners<E> =
|
||||||
if (registries.containsKey(clazz)) {
|
if (registries.containsKey(clazz)) registries[clazz] as EventListeners<E>
|
||||||
return registries[clazz] as EventListeners<E>
|
else registriesMutex.withLock {
|
||||||
} else {
|
|
||||||
EventListeners<E>().let {
|
EventListeners<E>().let {
|
||||||
registries[clazz] = it
|
registries[clazz] = it
|
||||||
return it
|
return it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
internal suspend fun <E : Subscribable> E.broadcastInternal(): E {
|
internal suspend fun <E : Subscribable> E.broadcastInternal(): E {
|
||||||
|
Loading…
Reference in New Issue
Block a user