From 42f248e074d35425fed0b5df4cf96d08bcbad53b Mon Sep 17 00:00:00 2001 From: shedaniel Date: Sun, 19 Jun 2022 02:49:23 +0800 Subject: Synchronize DisplayRegistry displays --- .../rei/impl/client/registry/display/DisplayRegistryImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'runtime') diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java index 73bf3122c..eaa53a23d 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/client/registry/display/DisplayRegistryImpl.java @@ -56,7 +56,7 @@ import java.util.function.UnaryOperator; public class DisplayRegistryImpl extends RecipeManagerContextImpl implements DisplayRegistry { private final WeakHashMap displaysBase = new WeakHashMap<>(); - private final Map, DisplaysList> displays = new ConcurrentHashMap<>(); + private final Map, List> displays = new ConcurrentHashMap<>(); private final Map, List> unmodifiableDisplays; private final Map, List>> displayGenerators = new ConcurrentHashMap<>(); private final List> globalDisplayGenerators = new ArrayList<>(); @@ -130,9 +130,11 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl { private final List unmodifiableList; + private final List synchronizedList; public DisplaysList() { - this.unmodifiableList = Collections.unmodifiableList(this); + this.synchronizedList = Collections.synchronizedList(this); + this.unmodifiableList = Collections.unmodifiableList(synchronizedList); } } @@ -159,7 +161,7 @@ public class DisplayRegistryImpl extends RecipeManagerContextImpl new DisplaysList()) + displays.computeIfAbsent(display.getCategoryIdentifier(), location -> new DisplaysList().synchronizedList) .add(display); displayCount.increment(); if (origin != null) { -- cgit