11
11
//===----------------------------------------------------------------------===//
12
12
13
13
import TSCBasic
14
+ import Foundation
14
15
15
16
// An inter-module dependency oracle, responsible for responding to queries about
16
17
// dependencies of a given module, caching already-discovered dependencies along the way.
@@ -42,26 +43,28 @@ public class InterModuleDependencyOracle {
42
43
swiftScanLibInstance = try SwiftScan ( dylib: swiftScanLibPath)
43
44
}
44
45
45
- public func getDependencies( workingDirectory: AbsolutePath ,
46
- commandLine: [ String ] ) throws -> InterModuleDependencyGraph {
47
- try self . lock. withLock {
46
+ @_spi ( Testing) public func getDependencies( workingDirectory: AbsolutePath ,
47
+ commandLine: [ String ] )
48
+ throws -> InterModuleDependencyGraph {
49
+ try queue. sync {
48
50
return try swiftScanLibInstance. scanDependencies ( workingDirectory: workingDirectory,
49
51
invocationCommand: commandLine)
50
52
}
51
53
}
52
54
53
- public func getBatchDependencies( workingDirectory: AbsolutePath ,
54
- commandLine: [ String ] ,
55
- batchInfos: [ BatchScanModuleInfo ] )
55
+ func getBatchDependencies( workingDirectory: AbsolutePath ,
56
+ commandLine: [ String ] ,
57
+ batchInfos: [ BatchScanModuleInfo ] )
56
58
throws -> [ ModuleDependencyId : [ InterModuleDependencyGraph ] ] {
57
- try self . lock . withLock {
59
+ try queue . sync {
58
60
return try swiftScanLibInstance. batchScanDependencies ( workingDirectory: workingDirectory,
59
61
invocationCommand: commandLine,
60
62
batchInfos: batchInfos)
61
63
}
62
64
}
63
65
64
- internal let lock = Lock ( )
66
+ /// Queue to sunchronize accesses to the scanner
67
+ internal let queue = DispatchQueue ( label: " org.swift.swift-driver.swift-scan " )
65
68
66
69
/// A reference to an instance of the compiler's libSwiftScan shared library
67
70
private let swiftScanLibInstance : SwiftScan
@@ -74,8 +77,8 @@ public class InterModuleDependencyOracle {
74
77
/// from the concept of a placeholder module so we should be able to get rid of this in the future.
75
78
internal var externalModules : ModuleInfoMap = [ : ]
76
79
/// Query the ModuleInfo of a module with a given ID
77
- public func getExternalModuleInfo( of moduleId: ModuleDependencyId ) -> ModuleInfo ? {
78
- self . lock . withLock {
80
+ @ _spi ( Testing ) public func getExternalModuleInfo( of moduleId: ModuleDependencyId ) -> ModuleInfo ? {
81
+ queue . sync {
79
82
return externalModules [ moduleId]
80
83
}
81
84
}
0 commit comments