RLMThreadSafeReference

Objective-C


@interface RLMThreadSafeReference<__covariant Confined : id <RLMThreadConfined>>
    : NSObject

迅速

@_nonSendable(_assumed) class RLMThreadSafeReference<Confined> : NSObject, @unchecked Sendable where Confined : RLMThreadConfined

要在线程之间传递的对象,其中包含对其线程限制对象的线程安全引用。

要在不同线程上解析目标 Realm 的线程安全引用,请传递给-[RLMRealm resolveThreadSafeReference:]

警告

RLMThreadSafeReference对象最多必须解析一次。 无法解析RLMThreadSafeReference将导致 Realm 的源版本被固定,直到引用被解除分配。

注意

首选短期RLMThreadSafeReference ,因为源 Realm 版本的数据将保留,直到所有引用都已解析或解除分配。

  • 创建对线程限制对象的线程安全引用。

    注意

    在将线程对象传递给此构造函数后,您可以继续使用和访问该对象。

    声明

    Objective-C

    + (nonnull instancetype)referenceWithThreadConfined:
        (nonnull Confined)threadConfined;

    迅速

    convenience init(threadConfined: Confined)

    参数

    threadConfined

    要创建线程安全引用的线程对象。

  • 指示是否由于已尝试解析引用而无法再解析该引用。 引用只能解析一次。

    声明

    Objective-C

    @property (nonatomic, readonly, getter=isInvalidated) BOOL invalidated;

    迅速

    var isInvalidated: Bool { get }

不可用的方法

  • 不可用

    无法直接创建 RLMThreadSafeReference

    -[RLMThreadSafeReference init] 不可用,因为无法直接创建RLMThreadSafeReferenceRLMThreadSafeReference实例必须通过调用-[RLMRealm resolveThreadSafeReference:]来获取。

    声明

    Objective-C

    - (nonnull instancetype)init;
  • 不可用

    无法直接创建 RLMThreadSafeReference

    -[RLMThreadSafeReference new] 不可用,因为无法直接创建RLMThreadSafeReferenceRLMThreadSafeReference实例必须通过调用-[RLMRealm resolveThreadSafeReference:]来获取。

    声明

    Objective-C

    + (nonnull instancetype)new;