ECS: make library lookup thread safe

This commit is contained in:
Jakub Valtar
2016-05-03 12:16:58 +02:00
parent 694436c724
commit 8885c38b68
2 changed files with 7 additions and 2 deletions
+6 -1
View File
@@ -282,7 +282,7 @@ public abstract class Mode {
public void rebuildLibraryList() {
//new Exception("Rebuilding library list").printStackTrace(System.out);
// reset the table mapping imports to libraries
importToLibraryTable = new HashMap<String, List<Library>>();
HashMap<String, List<Library>> importToLibraryTable = new HashMap<>();
Library core = getCoreLibrary();
if (core != null) {
@@ -323,6 +323,11 @@ public abstract class Mode {
for (Library lib : contribLibraries) {
lib.addPackageList(importToLibraryTable);
}
// Make this Map thread-safe
this.importToLibraryTable = Collections.unmodifiableMap(importToLibraryTable);
base.getEditors().forEach(Editor::librariesChanged);
}
@@ -703,7 +703,7 @@ public class ErrorCheckerService {
.filter(pckg -> !ignorableImport(pckg))
.map(pckg -> {
try {
return mode.getLibrary(pckg); // TODO: this may not be thread-safe
return mode.getLibrary(pckg);
} catch (SketchException e) {
return null;
}