Skip to content

Commit

Permalink
Fix NSRecursiveLock API
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuawright11 committed Sep 1, 2023
1 parent 94b059e commit d1913ea
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions Sources/Alchemy/Services/Container/Container.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,20 @@ public final class Container: CustomDebugStringConvertible {
"""
}
}

#if os(Linux)
extension NSRecursiveLock {
fileprivate func withLock<R>(_ body: () throws -> R) rethrows -> R {
self.lock()
let value: R
do {
value = try body()
} catch {
self.unlock()
throw error
}
self.unlock()
return value
}
}
#endif

0 comments on commit d1913ea

Please sign in to comment.