Update SuspendLazy

Koitharu 2 years ago
parent 5758e9f68f
commit 87f99addbb
Signed by: Koitharu
GPG Key ID: 676DEE768C17A9D7

@ -30,4 +30,8 @@ class SoftSuspendLazy<T : Any>(
}
suspend fun tryGet() = runCatchingCancellable { get() }
fun peek(): T? {
return cachedValue?.get()
}
}

@ -32,5 +32,10 @@ class SuspendLazy<T>(
suspend fun tryGet() = runCatchingCancellable { get() }
@Suppress("UNCHECKED_CAST")
fun peek(): T? {
return cachedValue?.takeUnless { it === Uninitialized } as T?
}
private object Uninitialized
}

Loading…
Cancel
Save