util.Once.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of experiment-jvm-server Show documentation
Show all versions of experiment-jvm-server Show documentation
Amplitude Experiment server-side SDK for JVM (Java, Kotlin)
package com.amplitude.experiment.util
class Once {
private var done = false
fun once(block: () -> Unit) {
synchronized(this) {
if (done) return@once
done = true
}
try {
block.invoke()
} catch (t: Throwable) {
synchronized(this) {
done = false
}
throw t
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy