Instance Methodswift-nio 2.72.0NIOConcurrencyHelpers
withLock(_:)
Acquire the lock for the duration of the given block.
lock.swift:107This 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
init(
) Create a new lock.
Instance members
Show obsolete interfaces (3)
Hide obsolete interfaces
func lock(
) Acquire the lock.
func unlock(
) Release the lock.
func withLockVoid(() throws -> Void
) rethrows