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

commonMain.algorithms.EmptyWeakRef.kt Maven / Gradle / Ivy

There is a newer version: 3.0.0-alpha.1
Show newest version
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