File tree Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Expand file tree Collapse file tree 2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change 1010//
1111//===----------------------------------------------------------------------===//
1212
13+ import class Foundation. NSLock
1314import 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+ }
Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments