MetadataLock

open class MetadataLock : ObjectBase

A lock for ensuring thread-safe access to mutable service metadata. See ReadWriteLock for notes regarding lock reentrancy for writers.

  • Default initializer.

    Declaration

    Swift

    override public init()
  • Read and write mutex.

    Declaration

    Swift

    open var mutex: ReadWriteMutex { get }
  • Lock metadata while performing an action that doesn’t change metadata. To separate the locking and unlocking steps, see mutex, ReadWriteLock.beginRead and ReadWriteLock.endRead. Note: a thread may request a read lock when it already has a read lock (but not if it already has a write lock).

    Declaration

    Swift

    open func readLock(action: @escaping () throws -> Void) throws

    Parameters

    action

    Action to perform while a shared read lock is held.

  • Lock metadata while performing an action that changes metadata. To separate the locking and unlocking steps, see mutex, ReadWriteLock.beginWrite and ReadWriteLock.endWrite. Note: If a thread tries to acquire a write lock while already holding a (read or write) lock, the thread will hang.

    Declaration

    Swift

    open func writeLock(action: @escaping () throws -> Void) throws

    Parameters

    action

    Action to perform while an exclusive write lock is held.