Skip to content

Commit

Permalink
Merge pull request #442 from xpdota/refactor-loading
Browse files Browse the repository at this point in the history
Refactor loading
  • Loading branch information
xpdota authored Oct 7, 2023
2 parents 27de539 + 5f28dd1 commit 2156d20
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,14 @@
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 TopologyInfo topoInfo;
private final Map<Class<? extends Event>, List<EventHandler<Event>>> eventClassMap = new HashMap<>();
private final List<@NotNull EventHandler<Event>> autoHandlers = new ArrayList<>();
private final List<@NotNull EventHandler<Event>> manualHandlers = new ArrayList<>();
Expand All @@ -38,20 +41,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<Event>) 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) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions xivsupport/src/main/resources/te_changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ <h2>Beta</h2>
<li>Easy Triggers: New actions to wait for a buff/cast remaining duration to be below a certain time. Useful
for having a reminder of when a buff is about to expire.
</li>
<li>Some internal refactoring.</li>
</ul>
<h2>Sep 3, 2023</h2>
<ul>
Expand Down

0 comments on commit 2156d20

Please sign in to comment.