
commonMain.algorithms.EmptyWeakRef.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of weak-jvm Show documentation
Show all versions of weak-jvm Show documentation
Weak references and maps for Kotlin Multiplatform
package opensavvy.pedestal.weak.algorithms
import opensavvy.pedestal.weak.ExperimentalWeakApi
import opensavvy.pedestal.weak.WeakRef
private object EmptyWeakRefImpl : WeakRef {
override fun read(): Nothing? = null
override fun toString() = "EmptyWeakRef"
}
/**
* A [WeakRef] implementation that doesn't store any value.
*
* It acts as if there was a value, but it was immediately freed.
*/
@Suppress("FunctionName")
@ExperimentalWeakApi
fun EmptyWeakRef(): WeakRef =
EmptyWeakRefImpl
/**
* A [WeakRef] implementation that immediately frees its [value].
*/
@Suppress("UNUSED_PARAMETER", "FunctionName")
@ExperimentalWeakApi
fun EmptyWeakRef(value: T): WeakRef =
EmptyWeakRefImpl
© 2015 - 2025 Weber Informatics LLC | Privacy Policy