All Downloads are FREE. Search and download functionalities are using the official Maven repository.

util.Once.kt Maven / Gradle / Ivy

There is a newer version: 1.6.1
Show newest version
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