diff options
| author | shedaniel <daniel@shedaniel.me> | 2021-11-07 16:21:34 +0800 |
|---|---|---|
| committer | shedaniel <daniel@shedaniel.me> | 2021-11-07 16:21:34 +0800 |
| commit | f8fc41207ca444c0a90ae10d78a821831b245bc2 (patch) | |
| tree | a2a049cc4ead3157eb9d284027e12798f9e48c81 /runtime/src/main/java/me/shedaniel/rei/impl/common | |
| parent | d1e91e2e2ffa317a52e659f2ca2b76800108f427 (diff) | |
| download | RoughlyEnoughItems-f8fc41207ca444c0a90ae10d78a821831b245bc2.tar.gz RoughlyEnoughItems-f8fc41207ca444c0a90ae10d78a821831b245bc2.tar.bz2 RoughlyEnoughItems-f8fc41207ca444c0a90ae10d78a821831b245bc2.zip | |
Fix #654
Diffstat (limited to 'runtime/src/main/java/me/shedaniel/rei/impl/common')
2 files changed, 8 insertions, 2 deletions
diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/logging/performance/PerformanceLoggerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/logging/performance/PerformanceLoggerImpl.java index 934bf494e..227d067c7 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/logging/performance/PerformanceLoggerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/logging/performance/PerformanceLoggerImpl.java @@ -28,14 +28,16 @@ import com.google.common.collect.Maps; import com.mojang.datafixers.util.Pair; import it.unimi.dsi.fastutil.objects.Object2LongLinkedOpenHashMap; import it.unimi.dsi.fastutil.objects.Object2LongMap; +import it.unimi.dsi.fastutil.objects.Object2LongMaps; import me.shedaniel.rei.api.common.plugins.REIPlugin; import me.shedaniel.rei.api.common.plugins.REIPluginProvider; +import java.util.Collections; import java.util.Map; import java.util.concurrent.TimeUnit; public class PerformanceLoggerImpl implements PerformanceLogger { - private final Map<String, PluginImpl> stages = Maps.newLinkedHashMap(); + private final Map<String, PluginImpl> stages = Collections.synchronizedMap(Maps.newLinkedHashMap()); @Override public Plugin stage(String stage) { @@ -52,7 +54,7 @@ public class PerformanceLoggerImpl implements PerformanceLogger { private static class PluginImpl implements Plugin { private final Stopwatch stopwatch = Stopwatch.createUnstarted(); private long totalTime = 0; - private Object2LongMap<Object> times = new Object2LongLinkedOpenHashMap<>(); + private Object2LongMap<Object> times = Object2LongMaps.synchronize(new Object2LongLinkedOpenHashMap<>()); @Override public Inner stage(String stage) { diff --git a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java index 71b1cb716..bda591fb1 100644 --- a/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java +++ b/runtime/src/main/java/me/shedaniel/rei/impl/common/plugins/PluginManagerImpl.java @@ -213,6 +213,8 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< ((REIPlugin<P>) plugin.plugin).preStage(this, stage); } }); + } catch (Throwable throwable) { + new RuntimeException("Failed to run pre registration").printStackTrace(); } } @@ -229,6 +231,8 @@ public class PluginManagerImpl<P extends REIPlugin<?>> implements PluginManager< ((REIPlugin<P>) plugin.plugin).postStage(this, stage); } }); + } catch (Throwable throwable) { + new RuntimeException("Failed to run post registration").printStackTrace(); } } |
