fix(ModuleServiceImpl): restoreVisibility concurrency
This commit is contained in:
@@ -3,12 +3,12 @@ package de.extio.game_engine.module;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
|
||||||
import java.util.EnumMap;
|
import java.util.EnumMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Stack;
|
import java.util.Stack;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
@@ -50,7 +50,7 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
|||||||
|
|
||||||
private final Map<ModuleExecutorCallbacks, List<AbstractModule>> executorCallbackMap = Collections.synchronizedMap(new EnumMap<>(ModuleExecutorCallbacks.class));
|
private final Map<ModuleExecutorCallbacks, List<AbstractModule>> executorCallbackMap = Collections.synchronizedMap(new EnumMap<>(ModuleExecutorCallbacks.class));
|
||||||
|
|
||||||
public ModuleServiceImpl(ApplicationContext applicationContext, final RendererWorkingSet rendererWorkingSet, final EventService eventService) {
|
public ModuleServiceImpl(final ApplicationContext applicationContext, final RendererWorkingSet rendererWorkingSet, final EventService eventService) {
|
||||||
this.applicationContext = applicationContext;
|
this.applicationContext = applicationContext;
|
||||||
this.rendererWorkingSet = rendererWorkingSet;
|
this.rendererWorkingSet = rendererWorkingSet;
|
||||||
this.eventService = eventService;
|
this.eventService = eventService;
|
||||||
@@ -58,7 +58,7 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
|||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
public void onApplicationEvent(final ContextRefreshedEvent event) {
|
||||||
final var modulesInitial = this.applicationContext.getBeansOfType(AbstractModule.class, false, false);
|
final var modulesInitial = this.applicationContext.getBeansOfType(AbstractModule.class, false, false);
|
||||||
if (modulesInitial == null || modulesInitial.isEmpty()) {
|
if (modulesInitial == null || modulesInitial.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
@@ -300,11 +300,11 @@ public class ModuleServiceImpl implements ModuleService, ApplicationListener<Con
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void restoreVisibility() {
|
public void restoreVisibility() {
|
||||||
|
synchronized (this.lastVisibleStates) {
|
||||||
if (this.lastVisibleStates.isEmpty()) {
|
if (this.lastVisibleStates.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized (this.lastVisibleStates) {
|
|
||||||
for (final AbstractClientModule module : this.lastVisibleStates.pop()) {
|
for (final AbstractClientModule module : this.lastVisibleStates.pop()) {
|
||||||
this.changeDisplayState(module.getId(), true);
|
this.changeDisplayState(module.getId(), true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user