mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Dependency Scanning] Synchronize on updating Swift dependency lookup results in-parallel
Resolves rdar://142978967
This commit is contained in:
@@ -926,16 +926,19 @@ void ModuleDependencyScanner::resolveSwiftImportsForModule(
|
||||
for (const auto &dependsOn : moduleDependencyInfo.getModuleImports())
|
||||
moduleLookupResult.insert(
|
||||
std::make_pair(dependsOn.importIdentifier, std::nullopt));
|
||||
std::mutex lookupResultLock;
|
||||
|
||||
// A scanning task to query a module by-name. If the module already exists
|
||||
// in the cache, do nothing and return.
|
||||
auto scanForSwiftModuleDependency =
|
||||
[this, &cache, &moduleLookupResult](Identifier moduleIdentifier,
|
||||
bool isTestable) {
|
||||
[this, &cache, &lookupResultLock, &moduleLookupResult](Identifier moduleIdentifier,
|
||||
bool isTestable) {
|
||||
auto moduleName = moduleIdentifier.str().str();
|
||||
// If this is already in the cache, no work to do here
|
||||
if (cache.hasSwiftDependency(moduleName))
|
||||
return;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(lookupResultLock);
|
||||
if (cache.hasSwiftDependency(moduleName))
|
||||
return;
|
||||
}
|
||||
|
||||
auto moduleDependencies = withDependencyScanningWorker(
|
||||
[&cache, moduleIdentifier,
|
||||
@@ -944,7 +947,11 @@ void ModuleDependencyScanner::resolveSwiftImportsForModule(
|
||||
moduleIdentifier, cache.getModuleOutputPath(),
|
||||
cache.getScanService().getPrefixMapper(), isTestable);
|
||||
});
|
||||
moduleLookupResult.insert_or_assign(moduleName, moduleDependencies);
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(lookupResultLock);
|
||||
moduleLookupResult.insert_or_assign(moduleName, moduleDependencies);
|
||||
}
|
||||
};
|
||||
|
||||
// Enque asynchronous lookup tasks
|
||||
|
||||
Reference in New Issue
Block a user