@@ -928,16 +928,19 @@ void ModuleDependencyScanner::resolveSwiftImportsForModule(
928
928
for (const auto &dependsOn : moduleDependencyInfo.getModuleImports ())
929
929
moduleLookupResult.insert (
930
930
std::make_pair (dependsOn.importIdentifier , std::nullopt));
931
+ std::mutex lookupResultLock;
931
932
932
933
// A scanning task to query a module by-name. If the module already exists
933
934
// in the cache, do nothing and return.
934
935
auto scanForSwiftModuleDependency =
935
- [this , &cache, &moduleLookupResult](Identifier moduleIdentifier,
936
- bool isTestable) {
936
+ [this , &cache, &lookupResultLock, & moduleLookupResult](Identifier moduleIdentifier,
937
+ bool isTestable) {
937
938
auto moduleName = moduleIdentifier.str ().str ();
938
- // If this is already in the cache, no work to do here
939
- if (cache.hasSwiftDependency (moduleName))
940
- return ;
939
+ {
940
+ std::lock_guard<std::mutex> guard (lookupResultLock);
941
+ if (cache.hasSwiftDependency (moduleName))
942
+ return ;
943
+ }
941
944
942
945
auto moduleDependencies = withDependencyScanningWorker (
943
946
[&cache, moduleIdentifier,
@@ -946,7 +949,11 @@ void ModuleDependencyScanner::resolveSwiftImportsForModule(
946
949
moduleIdentifier, cache.getModuleOutputPath (),
947
950
cache.getScanService ().getPrefixMapper (), isTestable);
948
951
});
949
- moduleLookupResult.insert_or_assign (moduleName, moduleDependencies);
952
+
953
+ {
954
+ std::lock_guard<std::mutex> guard (lookupResultLock);
955
+ moduleLookupResult.insert_or_assign (moduleName, moduleDependencies);
956
+ }
950
957
};
951
958
952
959
// Enque asynchronous lookup tasks
0 commit comments