Skip to content

Commit da1b3fe

Browse files
author
lukas.molzberger
committed
- more synchronization
1 parent 4f0af16 commit da1b3fe

File tree

1 file changed

+12
-6
lines changed

1 file changed

+12
-6
lines changed

core/src/main/java/network/aika/Model.java

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,19 +83,25 @@ public long createNeuronId() {
8383
}
8484

8585
public Long getLowestDocumentId() {
86-
try {
87-
return documents.firstKey();
88-
} catch (NoSuchElementException e) {
89-
return null;
86+
synchronized (documents) {
87+
try {
88+
return documents.firstKey();
89+
} catch (NoSuchElementException e) {
90+
return null;
91+
}
9092
}
9193
}
9294

9395
public void registerDocument(Document doc) {
94-
documents.put(doc.getId(), doc);
96+
synchronized (documents) {
97+
documents.put(doc.getId(), doc);
98+
}
9599
}
96100

97101
public void deregisterDocument(Document doc) {
98-
documents.remove(doc.getId());
102+
synchronized (documents) {
103+
documents.remove(doc.getId());
104+
}
99105

100106
lastProcessedDocument = Math.max(lastProcessedDocument, doc.getId());
101107
}

0 commit comments

Comments
 (0)