mirror of
https://github.com/DiscordSRV/Ascension.git
synced 2025-02-08 00:21:38 +01:00
Add waiting for console processing to be done in shutdown, check to not queue stuff when console handler is shutdown
This commit is contained in:
parent
812f459d93
commit
e0bee7e2d8
@ -43,6 +43,7 @@ public class SingleConsoleHandler {
|
||||
private final ConsoleConfig config;
|
||||
private final Queue<LogEntry> queue = new LinkedBlockingQueue<>();
|
||||
private Future<?> queueProcessingFuture;
|
||||
private boolean shutdown = false;
|
||||
|
||||
// Editing
|
||||
private final List<LogMessage> messageCache;
|
||||
@ -163,8 +164,14 @@ public class SingleConsoleHandler {
|
||||
}
|
||||
|
||||
public void shutdown() {
|
||||
shutdown = true;
|
||||
discordSRV.eventBus().unsubscribe(this);
|
||||
queueProcessingFuture.cancel(false);
|
||||
try {
|
||||
queueProcessingFuture.wait(TimeUnit.SECONDS.toMillis(3));
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
}
|
||||
queue.clear();
|
||||
if (messageCache != null) {
|
||||
messageCache.clear();
|
||||
@ -173,6 +180,9 @@ public class SingleConsoleHandler {
|
||||
}
|
||||
|
||||
private void timeQueueProcess() {
|
||||
if (shutdown) {
|
||||
return;
|
||||
}
|
||||
this.queueProcessingFuture = discordSRV.scheduler().runLater(this::processQueue, 2, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user