Classes
class WeakRef<T> where T <: Object
public class WeakRef<T> <: WeakRefBase where T <: Object {
public init(value: T, cleanupPolicy: CleanupPolicy)
}
Description: Provides functionalities related to weak references. If the reference to an object is marked as a weak reference, the GC can reclaim the object according to the specified reclamation policy even if the reference is not null and the object is still reachable.
prop cleanupPolicy
public prop cleanupPolicy: CleanupPolicy
Description: Obtains the reclamation policy for the weak reference.
Type: CleanupPolicy
prop value
public prop value: Option<T>
Description: Reads the object referenced by the weak reference. None is returned if the weak reference is null or the object referenced by the weak reference has been reclaimed.
Type: Option<T>
init(T, CleanupPolicy)
public init(value: T, cleanupPolicy: CleanupPolicy)
Description: Creates a weak reference for the value object and specifies a reclamation policy.
Parameters:
- value: T: object referenced by the weak reference
- cleanupPolicy: CleanupPolicy: reclamation policy for the
valueobject
func clear()
public func clear(): Unit
Description: Forcibly reclaims the object referenced by the weak reference. None is returned for subsequent access to value.
class WeakRefBase
sealed abstract class WeakRefBase
This class does not contain any public members or public functions, and cannot be inherited or extended. It is used only as the base class for WeakRef.