NativeLock

public final class NativeLock : Locking

A variant lock backed by a platform type that attempts to allow waiters to block efficiently on contention. This locking type behaves the same for both read and write locks.

  • On recent versions of Darwin (iOS 10.0, macOS 12.0, tvOS 1.0, watchOS 3.0, or better), this efficiency is a guarantee.
  • On Linux, BSD, or Android, waiters perform comparably to a kernel lock under contention.
  • Creates a standard platform lock.

    Declaration

    Swift

    public init()
  • Declaration

    Swift

    public func withReadLock<Return>(_ body: () throws -> Return) rethrows -> Return
  • Declaration

    Swift

    public func withAttemptedReadLock<Return>(_ body: () throws -> Return) rethrows -> Return?