Skip to content

Commit

Permalink
Use the thread pool for things so its shutdown properly
Browse files Browse the repository at this point in the history
Fixes #53
  • Loading branch information
rtm516 committed Jun 19, 2024
1 parent 7013745 commit 84d2052
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ private void restart() {
sessionManager = new SessionManager(this.dataFolder().toString(), logger);

// Pull onto another thread so we don't hang the main thread
new Thread(this::createSession);
sessionManager.scheduledThread().execute(this::createSession);
}

@Subscribe
Expand All @@ -112,7 +112,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
config = ConfigLoader.load(this, MCXboxBroadcastExtension.class, ExtensionConfig.class);

// Pull onto another thread so we don't hang the main thread
new Thread(() -> {
sessionManager.scheduledThread().execute(() -> {
// Get the ip to broadcast
String ip = config.remoteAddress();
if (ip.equals("auto")) {
Expand Down Expand Up @@ -152,7 +152,7 @@ public void onPostInitialize(GeyserPostInitializeEvent event) {
sessionInfo.setPort(port);

createSession();
}).start();
});
}

private void createSession() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public void init(SessionInfo sessionInfo, FriendSyncConfig friendSyncConfig) thr

// Create the sub-sessions in a new thread so we don't block the main thread
List<String> finalSubSessions = subSessions;
new Thread(() -> {
scheduledThreadPool.execute(() -> {
// Create the sub-session manager for each sub-session
for (String subSession : finalSubSessions) {
try {
Expand All @@ -107,7 +107,7 @@ public void init(SessionInfo sessionInfo, FriendSyncConfig friendSyncConfig) thr
// TODO Retry creation after 30s or so
}
}
}).start();
});
}

@Override
Expand Down

0 comments on commit 84d2052

Please sign in to comment.