From d466c09cc837d968826f1321b3a15ea7c757f041 Mon Sep 17 00:00:00 2001 From: XP Date: Wed, 27 Sep 2023 20:10:47 -0700 Subject: [PATCH 1/2] Clean up module loading --- .../reevent/events/MonitoringEventDistributor.java | 12 ++++-------- .../java/gg/xp/xivsupport/gui/tabs/UpdatesPanel.java | 10 +++++++++- xivsupport/src/main/resources/te_changelog.html | 1 + 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java b/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java index 38b62593a006..7165ddcaac08 100644 --- a/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java +++ b/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java @@ -21,11 +21,13 @@ import java.util.List; import java.util.Map; +/** + * Event distributor that uses a component monitor to add handlers as they are loaded in. + */ public class MonitoringEventDistributor extends BasicEventDistributor implements TopologyProvider { private static final Logger log = LoggerFactory.getLogger(MonitoringEventDistributor.class); private final AutoScan scanner; private final TopologyInfo topoInfo; - private final Object loadLock = new Object(); private final Map, List>> eventClassMap = new HashMap<>(); private final List<@NotNull EventHandler> autoHandlers = new ArrayList<>(); private final List<@NotNull EventHandler> manualHandlers = new ArrayList<>(); @@ -38,20 +40,16 @@ public MonitoringEventDistributor(StateStore state, AutoScan scanner, TopologyIn boolean dirty = false; Object inst = item.instance(); if (inst instanceof EventHandler eh) { -// synchronized (loadLock) { autoHandlers.add((EventHandler) eh); dirty = true; -// } } Class clazz = inst.getClass(); Method[] methods = clazz.getMethods(); for (Method method : methods) { if (method.isAnnotationPresent(HandleEvents.class)) { AutoHandler rawEvh = new AutoHandler(clazz, method, inst, config); -// synchronized (loadLock) { autoHandlers.add(rawEvh); dirty = true; -// } } } if (dirty) { @@ -77,13 +75,11 @@ public void reloadIfNeeded() { if (!dirty) { return; } - log.info("Reloading", new RuntimeException()); -// synchronized (loadLock) { + log.info("Reloading"); handlers.clear(); handlers.addAll(manualHandlers); handlers.addAll(autoHandlers); sortHandlers(); -// } topology = Topology.fromHandlers(new ArrayList<>(this.handlers), topoInfo); dirty = false; } diff --git a/xivsupport/src/main/java/gg/xp/xivsupport/gui/tabs/UpdatesPanel.java b/xivsupport/src/main/java/gg/xp/xivsupport/gui/tabs/UpdatesPanel.java index a9f4f291d9cb..5dbc4c14f836 100644 --- a/xivsupport/src/main/java/gg/xp/xivsupport/gui/tabs/UpdatesPanel.java +++ b/xivsupport/src/main/java/gg/xp/xivsupport/gui/tabs/UpdatesPanel.java @@ -99,7 +99,15 @@ public UpdatesPanel(PersistenceProvider pers, UpdaterConfig updateConfig) { new RefreshLoop<>( "UpdatePeriodicCheck", this, - i -> doUpdateCheckInBackground(), + i -> { + try { + Thread.sleep(10_000); + } + catch (InterruptedException e) { + // + } + doUpdateCheckInBackground(); + }, // 15 minutes * 60 seconds * 1000 ms i -> 15 * 60 * 1000L ).start(); diff --git a/xivsupport/src/main/resources/te_changelog.html b/xivsupport/src/main/resources/te_changelog.html index 0abae9c8babb..8ac3e573c234 100644 --- a/xivsupport/src/main/resources/te_changelog.html +++ b/xivsupport/src/main/resources/te_changelog.html @@ -11,6 +11,7 @@

Beta

href="https://triggevent.io/pages/docs/Sequential-Triggers/#concurrency-mode">the website for more info. +
  • Some internal refactoring.
  • Sep 3, 2023

      From 5f28dd136e6d90fc7cf1fc9c3b42bd2040ab10bd Mon Sep 17 00:00:00 2001 From: XP Date: Fri, 6 Oct 2023 16:23:13 -0700 Subject: [PATCH 2/2] Fix merge conflict --- .../java/gg/xp/reevent/events/MonitoringEventDistributor.java | 1 + 1 file changed, 1 insertion(+) diff --git a/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java b/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java index 929c5841e514..44d46389b695 100644 --- a/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java +++ b/xivsupport/src/main/java/gg/xp/reevent/events/MonitoringEventDistributor.java @@ -27,6 +27,7 @@ public class MonitoringEventDistributor extends BasicEventDistributor implements TopologyProvider { private static final Logger log = LoggerFactory.getLogger(MonitoringEventDistributor.class); private final AutoScan scanner; + private final Object loadLock = new Object(); private final TopologyInfo topoInfo; private final Map, List>> eventClassMap = new HashMap<>(); private final List<@NotNull EventHandler> autoHandlers = new ArrayList<>();