WorkerBoundReference

class WorkerBoundReference<out T : Any>(value: T)

A shared reference to a Kotlin object that doesn't freeze the referred object when it gets frozen itself.

After freezing can be safely passed between workers, but value can only be accessed on the worker WorkerBoundReference was created on, unless the referred object is frozen too.

Note: Garbage collector currently cannot free any reference cycles with frozen WorkerBoundReference in them. To resolve such cycles consider using AtomicReference<WorkerBoundReference?> which can be explicitly nulled out.

Constructors

WorkerBoundReference
Link copied to clipboard
fun <out T : Any> WorkerBoundReference(value: T)

Properties

value
Link copied to clipboard
val value: T

The referenced value.

valueBeforeFreezing
Link copied to clipboard
var valueBeforeFreezing: T?
valueOrNull
Link copied to clipboard
val valueOrNull: T?

The referenced value or null if referred object is not frozen and current worker is different from the one created this.

worker
Link copied to clipboard
val worker: Worker

Worker that value is bound to.