Skip to content

Commit

Permalink
Make AttributeKey and VertexOperation registration synchronized.
Browse files Browse the repository at this point in the history
  • Loading branch information
covers1624 committed Sep 18, 2024
1 parent 2125097 commit 83b1a01
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
public interface IVertexOperation {

static int registerOperation() {
return VertexOperationRegistry.nextOperationIndex++;
return VertexOperationRegistry.nextOperationIndex();
}

static int operationCount() {
Expand All @@ -35,5 +35,9 @@ static int operationCount() {
class VertexOperationRegistry {

static int nextOperationIndex;

private static synchronized int nextOperationIndex() {
return VertexOperationRegistry.nextOperationIndex++;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public static class AttributeKeyRegistry {
private static final Map<String, AttributeKey<?>> nameMap = new HashMap<>();
private static final List<AttributeKey<?>> attributeKeys = new ArrayList<>();

private static int registerAttributeKey(AttributeKey<?> attr) {
private static synchronized int registerAttributeKey(AttributeKey<?> attr) {
if (nameMap.containsKey(attr.name)) {
throw new IllegalArgumentException("Duplicate registration of attribute with name: " + attr.name);
}
Expand Down

0 comments on commit 83b1a01

Please sign in to comment.