Commit efa404d0 authored by Him188's avatar Him188

Try fix compilation bug

parent 69ff3776
......@@ -90,6 +90,15 @@ internal object EventListenerManager {
private val lock = atomic(false)
private fun setLockValue(value: Boolean) {
lock.value = value
}
@Suppress("BooleanLiteralArgument")
private fun trySetLockTrue(): Boolean {
return lock.compareAndSet(false, true)
}
@Suppress("UNCHECKED_CAST", "BooleanLiteralArgument")
internal tailrec fun <E : Event> get(clazz: KClass<out E>): EventListeners<E> {
registries.forEach {
......@@ -97,10 +106,10 @@ internal object EventListenerManager {
return it.listeners as EventListeners<E>
}
}
if (lock.compareAndSet(false, true)) {
if (trySetLockTrue()) {
val registry = Registry(clazz, EventListeners())
registries.addLast(registry)
lock.value = false
setLockValue(false)
return registry.listeners as EventListeners<E>
}
return get(clazz)
......
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