Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion Sources/SwiftDriver/Execution/ArgsResolver.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
//
//===----------------------------------------------------------------------===//

import class Foundation.NSLock
import TSCBasic
@_implementationOnly import Yams

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

private let lock = Lock()
private let lock = NSLock()

public init(fileSystem: FileSystem, temporaryDirectory: VirtualPath? = nil) throws {
self.pathMapping = [:]
Expand Down Expand Up @@ -202,3 +203,13 @@ public final class ArgsResolver {
}
}
}

fileprivate extension NSLock {
/// NOTE: Keep in sync with SwiftPM's 'Sources/Basics/NSLock+Extensions.swift'
/// Execute the given block while holding the lock.
func withLock<T> (_ body: () throws -> T) rethrows -> T {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to add a note to keep this in sync with SPM?

lock()
defer { unlock() }
return try body()
}
}
3 changes: 0 additions & 3 deletions Sources/SwiftDriver/SwiftScan/SwiftScan.swift
Original file line number Diff line number Diff line change
Expand Up @@ -63,9 +63,6 @@ internal final class SwiftScan {
/// The handle to the dylib.
let dylib: Loader.Handle

/// Lock protecting private state.
let lock: Lock = Lock()

/// libSwiftScan API functions.
let api: swiftscan_functions_t;

Expand Down