ReferenceQueue

open class ReferenceQueue<T>

A simple mimic of Java's java.lang.ref.ReferenceQueue.

This implementation is a minimal, non‑blocking version that only mimics the API. It stores enqueued references in an internal list and ignores the concurrency, waiting, and GC‑integration that the real Java version provides.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion

Functions

Link copied to clipboard
open fun enqueue(ref: Reference<T>): Boolean

Enqueues the given reference.

Link copied to clipboard
open fun forEach(action: (Reference<T>) -> Unit)

Iterates over the queue and invokes the given action on each reference.

Link copied to clipboard
open fun poll(): Reference<T>?

Polls the queue to see if a reference object is available. If one is available, it is removed from the queue and returned. Otherwise, returns null.

Link copied to clipboard
open fun remove(): Reference<T>?

Removes the next reference object from this queue, blocking indefinitely until one becomes available.

open fun remove(timeout: Long): Reference<T>?

Removes the next reference object from this queue, blocking until one becomes available or the specified timeout (in milliseconds) expires.