ThreadSafeReference
@frozen
public struct ThreadSafeReference<Confined> where Confined : ThreadConfined
An object intended to be passed between threads containing a thread-safe reference to its thread-confined object.
To resolve a thread-safe reference on a target Realm on a different thread, pass to
Realm.resolve(_:)
.
Warning
A ThreadSafeReference
object must be resolved at most once.
Failing to resolve a ThreadSafeReference
will result in the source version of the
Realm being pinned until the reference is deallocated.
Note
Prefer short-lived ThreadSafeReference
s as the data for the version of the source Realm
will be retained until all references have been resolved or deallocated.
See
-
Indicates if the reference can no longer be resolved because an attempt to resolve it has already occurred. References can only be resolved once.
Declaration
Swift
public var isInvalidated: Bool { get }
-
Create a thread-safe reference to the thread-confined object.
Note
You may continue to use and access the thread-confined object after passing it to this constructor.
Declaration
Swift
public init(to threadConfined: Confined)
Parameters
threadConfined
The thread-confined object to create a thread-safe reference to.