Skip to content

Commit c40cbd5

Browse files
authored
Merge pull request #1160 from artemcm/LockFix
Remove use of deprecated STSC 'Lock'
2 parents c771555 + 5af9ca0 commit c40cbd5

File tree

2 files changed

+12
-4
lines changed

2 files changed

+12
-4
lines changed

Sources/SwiftDriver/Execution/ArgsResolver.swift

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
//
1111
//===----------------------------------------------------------------------===//
1212

13+
import class Foundation.NSLock
1314
import TSCBasic
1415
@_implementationOnly import Yams
1516

@@ -25,7 +26,7 @@ public final class ArgsResolver {
2526
// FIXME: We probably need a dedicated type for this...
2627
private let temporaryDirectory: VirtualPath
2728

28-
private let lock = Lock()
29+
private let lock = NSLock()
2930

3031
public init(fileSystem: FileSystem, temporaryDirectory: VirtualPath? = nil) throws {
3132
self.pathMapping = [:]
@@ -202,3 +203,13 @@ public final class ArgsResolver {
202203
}
203204
}
204205
}
206+
207+
fileprivate extension NSLock {
208+
/// NOTE: Keep in sync with SwiftPM's 'Sources/Basics/NSLock+Extensions.swift'
209+
/// Execute the given block while holding the lock.
210+
func withLock<T> (_ body: () throws -> T) rethrows -> T {
211+
lock()
212+
defer { unlock() }
213+
return try body()
214+
}
215+
}

Sources/SwiftDriver/SwiftScan/SwiftScan.swift

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,9 +63,6 @@ internal final class SwiftScan {
6363
/// The handle to the dylib.
6464
let dylib: Loader.Handle
6565

66-
/// Lock protecting private state.
67-
let lock: Lock = Lock()
68-
6966
/// libSwiftScan API functions.
7067
let api: swiftscan_functions_t;
7168

0 commit comments

Comments
 (0)