Skip to content

Commit

Permalink
ECS: make library lookup thread safe
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubValtar committed May 3, 2016
1 parent 4ac5c02 commit 49823a0
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion app/src/processing/app/Mode.java
Expand Up @@ -282,7 +282,7 @@ public File getReferenceFolder() {
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) {
Expand Down Expand Up @@ -323,6 +323,11 @@ public void rebuildLibraryList() {
for (Library lib : contribLibraries) {
lib.addPackageList(importToLibraryTable);
}

// Make this Map thread-safe
this.importToLibraryTable = Collections.unmodifiableMap(importToLibraryTable);

base.getEditors().forEach(Editor::librariesChanged);
}


Expand Down
Expand Up @@ -703,7 +703,7 @@ private List<String> buildSketchLibraryClassPath(JavaMode mode,
.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;
}
Expand Down

0 comments on commit 49823a0

Please sign in to comment.