commonMain.org.kodein.di.internal.concurrent.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of kodein-di-js Show documentation
Show all versions of kodein-di-js Show documentation
KODEIN Dependency Injection Core
package org.kodein.di.internal
public expect inline fun maySynchronized(lock: Any?, block: () -> R): R
/** @suppress */
public inline fun synchronizedIfNull(lock: Any?, predicate: () -> T?, ifNotNull: (T) -> R, ifNull: () -> R): R {
predicate()?.let {
return ifNotNull(it)
}
val value = maySynchronized(lock) {
predicate()?.let { return@maySynchronized it }
return ifNull()
}
return ifNotNull(value)
}
/** @suppress */
internal inline fun synchronizedIfNotNull(lock: Any?, predicate: () -> T?, ifNull: () -> R, ifNotNull: (T) -> R): R {
if (predicate() == null) {
return ifNull()
}
maySynchronized(lock) {
val value = predicate() ?: return@maySynchronized
return ifNotNull(value)
}
return ifNull()
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy