mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2024-12-29 12:37:40 +01:00
Limit the number of scheduler work threads
This commit is contained in:
parent
6fdd349654
commit
6325e25630
@ -223,7 +223,7 @@ public class LegacyImporter implements Runnable {
|
||||
private CommandResult result = CommandResult.FAILURE;
|
||||
|
||||
ImportCommand(CommandManager commandManager, int id, String command) {
|
||||
super(commandManager.getPlugin());
|
||||
super(commandManager.getPlugin(), Sender.IMPORT_UUID, Sender.IMPORT_NAME);
|
||||
this.commandManager = commandManager;
|
||||
this.id = id;
|
||||
this.command = command;
|
||||
|
@ -69,7 +69,6 @@ public class BulkUpdateCommand extends SingleCommand {
|
||||
}
|
||||
|
||||
if (args.size() == 2 && args.get(0).equalsIgnoreCase("confirm")) {
|
||||
|
||||
String id = args.get(1);
|
||||
BulkUpdate operation = this.pendingOperations.asMap().remove(id);
|
||||
|
||||
|
@ -32,6 +32,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import java.util.concurrent.Executor;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ForkJoinPool;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -46,35 +47,37 @@ public abstract class AbstractJavaScheduler implements SchedulerAdapter {
|
||||
.build()
|
||||
);
|
||||
|
||||
private final ErrorReportingExecutor workerPool = new ErrorReportingExecutor(Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
||||
private final ErrorReportingExecutor schedulerWorkerPool = new ErrorReportingExecutor(Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
||||
.setDaemon(true)
|
||||
.setNameFormat("luckperms-worker-%d")
|
||||
.setNameFormat("luckperms-scheduler-worker-%d")
|
||||
.build()
|
||||
));
|
||||
|
||||
private final ForkJoinPool worker = new ForkJoinPool(32, ForkJoinPool.defaultForkJoinWorkerThreadFactory, (t, e) -> e.printStackTrace(), false);
|
||||
|
||||
@Override
|
||||
public Executor async() {
|
||||
return this.workerPool;
|
||||
return this.worker;
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask asyncLater(Runnable task, long delay, TimeUnit unit) {
|
||||
ScheduledFuture<?> future = this.scheduler.schedule(() -> this.workerPool.execute(task), delay, unit);
|
||||
ScheduledFuture<?> future = this.scheduler.schedule(() -> this.schedulerWorkerPool.execute(task), delay, unit);
|
||||
return () -> future.cancel(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SchedulerTask asyncRepeating(Runnable task, long interval, TimeUnit unit) {
|
||||
ScheduledFuture<?> future = this.scheduler.scheduleAtFixedRate(() -> this.workerPool.execute(task), interval, interval, unit);
|
||||
ScheduledFuture<?> future = this.scheduler.scheduleAtFixedRate(() -> this.schedulerWorkerPool.execute(task), interval, interval, unit);
|
||||
return () -> future.cancel(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
this.scheduler.shutdown();
|
||||
this.workerPool.delegate.shutdown();
|
||||
this.schedulerWorkerPool.delegate.shutdown();
|
||||
try {
|
||||
this.workerPool.delegate.awaitTermination(1, TimeUnit.MINUTES);
|
||||
this.schedulerWorkerPool.delegate.awaitTermination(1, TimeUnit.MINUTES);
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -45,10 +45,6 @@ public abstract class DummySender implements Sender {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public DummySender(LuckPermsPlugin plugin) {
|
||||
this(plugin, Sender.IMPORT_UUID, Sender.IMPORT_NAME);
|
||||
}
|
||||
|
||||
protected abstract void consumeMessage(String s);
|
||||
|
||||
@Override
|
||||
|
Loading…
Reference in New Issue
Block a user