fix(core/event_dispatcher): cache concurrent calls

This commit is contained in:
rhunk
2024-02-13 18:17:01 +01:00
parent ba655a0e67
commit 08c9d46858

View File

@ -28,9 +28,11 @@ class EventDispatcher(
context.mappings.useMapper(ViewBinderMapper::class) {
val cachedHooks = mutableListOf<String>()
fun cacheHook(clazz: Class<*>, block: Class<*>.() -> Unit) {
if (!cachedHooks.contains(clazz.name)) {
clazz.block()
cachedHooks.add(clazz.name)
synchronized(cachedHooks) {
if (!cachedHooks.contains(clazz.name)) {
clazz.block()
cachedHooks.add(clazz.name)
}
}
}