Reference

open class Reference<T>(referent: T?, var queue: ReferenceQueue<T>? = (ReferenceQueue.NULL as ReferenceQueue<T>?))

A simple mimic of java.lang.ref.Reference.

This version only stores a reference and an associated queue, and provides basic operations like get, clear, and enqueue. It ignores the underlying GC, native methods, and thread-handling logic.

Inheritors

Constructors

Link copied to clipboard
constructor(referent: T?, queue: ReferenceQueue<T>? = (ReferenceQueue.NULL as ReferenceQueue<T>?))
constructor(referent: T)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open var queue: ReferenceQueue<T>?

Functions

Link copied to clipboard
open fun clear()

Clears this reference. The default implementation simply clears the referent.

Link copied to clipboard
open fun enqueue(): Boolean

Clears this reference and enqueues it in its associated ReferenceQueue, if any.

Link copied to clipboard
open fun get(): T?

Returns the referent or null if it has been cleared.

Link copied to clipboard
open fun refersTo(obj: T): Boolean

Checks whether the referent equals the given obj.