Skip to content

Commit 38ce8df

Browse files
Terkymerindorium
authored andcommitted
extensions: Add NSLock.withLock for Linux
1 parent 19efb31 commit 38ce8df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

Sources/Extensions/NSLock+.swift

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#if os(Linux)
2+
import Foundation
3+
4+
extension NSLock {
5+
6+
func withLock<R>(_ body: () throws -> R) rethrows -> R {
7+
lock()
8+
defer { unlock() }
9+
return try body()
10+
}
11+
}
12+
#endif

0 commit comments

Comments
 (0)