mirror of
https://github.com/LuckPerms/LuckPerms.git
synced 2025-01-01 14:07:56 +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;
|
private CommandResult result = CommandResult.FAILURE;
|
||||||
|
|
||||||
ImportCommand(CommandManager commandManager, int id, String command) {
|
ImportCommand(CommandManager commandManager, int id, String command) {
|
||||||
super(commandManager.getPlugin());
|
super(commandManager.getPlugin(), Sender.IMPORT_UUID, Sender.IMPORT_NAME);
|
||||||
this.commandManager = commandManager;
|
this.commandManager = commandManager;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.command = command;
|
this.command = command;
|
||||||
|
@ -69,7 +69,6 @@ public class BulkUpdateCommand extends SingleCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (args.size() == 2 && args.get(0).equalsIgnoreCase("confirm")) {
|
if (args.size() == 2 && args.get(0).equalsIgnoreCase("confirm")) {
|
||||||
|
|
||||||
String id = args.get(1);
|
String id = args.get(1);
|
||||||
BulkUpdate operation = this.pendingOperations.asMap().remove(id);
|
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.Executor;
|
||||||
import java.util.concurrent.ExecutorService;
|
import java.util.concurrent.ExecutorService;
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ForkJoinPool;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.ScheduledFuture;
|
import java.util.concurrent.ScheduledFuture;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -46,35 +47,37 @@ public abstract class AbstractJavaScheduler implements SchedulerAdapter {
|
|||||||
.build()
|
.build()
|
||||||
);
|
);
|
||||||
|
|
||||||
private final ErrorReportingExecutor workerPool = new ErrorReportingExecutor(Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
private final ErrorReportingExecutor schedulerWorkerPool = new ErrorReportingExecutor(Executors.newCachedThreadPool(new ThreadFactoryBuilder()
|
||||||
.setDaemon(true)
|
.setDaemon(true)
|
||||||
.setNameFormat("luckperms-worker-%d")
|
.setNameFormat("luckperms-scheduler-worker-%d")
|
||||||
.build()
|
.build()
|
||||||
));
|
));
|
||||||
|
|
||||||
|
private final ForkJoinPool worker = new ForkJoinPool(32, ForkJoinPool.defaultForkJoinWorkerThreadFactory, (t, e) -> e.printStackTrace(), false);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Executor async() {
|
public Executor async() {
|
||||||
return this.workerPool;
|
return this.worker;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchedulerTask asyncLater(Runnable task, long delay, TimeUnit unit) {
|
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);
|
return () -> future.cancel(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SchedulerTask asyncRepeating(Runnable task, long interval, TimeUnit unit) {
|
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);
|
return () -> future.cancel(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void shutdown() {
|
public void shutdown() {
|
||||||
this.scheduler.shutdown();
|
this.scheduler.shutdown();
|
||||||
this.workerPool.delegate.shutdown();
|
this.schedulerWorkerPool.delegate.shutdown();
|
||||||
try {
|
try {
|
||||||
this.workerPool.delegate.awaitTermination(1, TimeUnit.MINUTES);
|
this.schedulerWorkerPool.delegate.awaitTermination(1, TimeUnit.MINUTES);
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -45,10 +45,6 @@ public abstract class DummySender implements Sender {
|
|||||||
this.name = name;
|
this.name = name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DummySender(LuckPermsPlugin plugin) {
|
|
||||||
this(plugin, Sender.IMPORT_UUID, Sender.IMPORT_NAME);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected abstract void consumeMessage(String s);
|
protected abstract void consumeMessage(String s);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user