withLock(_:)

    Acquire the lock for the duration of the given block.

    lock.swift:107

    This declaration has been renamed to NIOLock.

    This declaration is deprecated.

    func withLock<T>(_ body: () throws -> T) rethrows -> T

    Parameters

    body

    The block to execute while holding the lock.

    Returns

    The value returned by the block.

    This convenience method should be preferred to lock and unlock in most situations, as it ensures that the lock will be released regardless of how body exits.

    Other members in extension

    Type members

    Show obsolete interfaces (1)

    Hide obsolete interfaces

    Instance members

    Show obsolete interfaces (3)

    Hide obsolete interfaces