Commit 0662dc83 authored by Him188's avatar Him188

Enhance performance

parent 09811224
......@@ -129,16 +129,15 @@ internal object EventListenerManger {
private val registriesMutex = Mutex()
@Suppress("UNCHECKED_CAST")
internal suspend fun <E : Subscribable> get(clazz: KClass<out E>): EventListeners<E> = registriesMutex.withLock {
if (registries.containsKey(clazz)) {
return registries[clazz] as EventListeners<E>
} else {
internal suspend fun <E : Subscribable> get(clazz: KClass<out E>): EventListeners<E> =
if (registries.containsKey(clazz)) registries[clazz] as EventListeners<E>
else registriesMutex.withLock {
EventListeners<E>().let {
registries[clazz] = it
return it
}
}
}
}
internal suspend fun <E : Subscribable> E.broadcastInternal(): E {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment