INNER CODE UNIT · Kotlin
onActive
M66B/FairEmail · app/src/main/java/androidx/lifecycle/ComputableLiveData.kt:48
override fun onActive() {
executor.execute(refreshRunnable)
}
}
/** The LiveData managed by this class. */
public open val liveData: LiveData<T?> = _liveData
internal val invalid = AtomicBoolean(true)
internal val computing = AtomicBoolean(false)
@JvmField
@VisibleForTesting
internal val refreshRunnable = Runnable {
var computed: Boolean
do {
computed = false
// compute can happen only in 1 thread but no reason to lock others.
if (computing.compareAndSet(false, true)) {
// as long as it is invalid, keep computing.