mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-02-04 14:41:39 +01:00
Cancel delayed/repeating tasks at the start of the disable process (#1935)
This commit is contained in:
parent
e9d72df890
commit
0864cf756c
@ -73,8 +73,12 @@ public class BungeeSchedulerAdapter implements SchedulerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
public void shutdownScheduler() {
|
||||
Iterators.tryIterate(this.tasks, ScheduledTask::cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownExecutor() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -205,6 +205,11 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
}
|
||||
|
||||
public final void disable() {
|
||||
getLogger().info("Starting shutdown process...");
|
||||
|
||||
// cancel delayed/repeating tasks
|
||||
getBootstrap().getScheduler().shutdownScheduler();
|
||||
|
||||
// shutdown permission vault and verbose handler tasks
|
||||
this.permissionRegistry.close();
|
||||
this.verboseHandler.close();
|
||||
@ -233,9 +238,8 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin {
|
||||
// unregister api
|
||||
ApiRegistrationUtil.unregisterProvider();
|
||||
|
||||
// shutdown scheduler
|
||||
getLogger().info("Shutting down internal scheduler...");
|
||||
getBootstrap().getScheduler().shutdown();
|
||||
// shutdown async executor pool
|
||||
getBootstrap().getScheduler().shutdownExecutor();
|
||||
|
||||
getLogger().info("Goodbye!");
|
||||
}
|
||||
|
@ -73,8 +73,17 @@ public abstract class AbstractJavaScheduler implements SchedulerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
public void shutdownScheduler() {
|
||||
this.scheduler.shutdown();
|
||||
try {
|
||||
this.scheduler.awaitTermination(1, TimeUnit.MINUTES);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownExecutor() {
|
||||
this.schedulerWorkerPool.delegate.shutdown();
|
||||
try {
|
||||
this.schedulerWorkerPool.delegate.awaitTermination(1, TimeUnit.MINUTES);
|
||||
|
@ -86,8 +86,17 @@ public interface SchedulerAdapter {
|
||||
SchedulerTask asyncRepeating(Runnable task, long interval, TimeUnit unit);
|
||||
|
||||
/**
|
||||
* Shuts down this executor instance
|
||||
* Shuts down the scheduler instance.
|
||||
*
|
||||
* <p>{@link #asyncLater(Runnable, long, TimeUnit)} and {@link #asyncRepeating(Runnable, long, TimeUnit)}.</p>
|
||||
*/
|
||||
void shutdown();
|
||||
void shutdownScheduler();
|
||||
|
||||
/**
|
||||
* Shuts down the executor instance.
|
||||
*
|
||||
* <p>{@link #async()} and {@link #executeAsync(Runnable)}.</p>
|
||||
*/
|
||||
void shutdownExecutor();
|
||||
|
||||
}
|
||||
|
@ -101,8 +101,12 @@ public class SpongeSchedulerAdapter implements SchedulerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
public void shutdownScheduler() {
|
||||
Iterators.tryIterate(this.tasks, Task::cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownExecutor() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
@ -80,8 +80,12 @@ public class VelocitySchedulerAdapter implements SchedulerAdapter {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
public void shutdownScheduler() {
|
||||
Iterators.tryIterate(this.tasks, ScheduledTask::cancel);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdownExecutor() {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user