net.minestom.server.timer.SchedulerManager Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.timer;
import org.jctools.queues.MpmcUnboundedXaddArrayQueue;
import org.jetbrains.annotations.NotNull;
import java.util.function.Supplier;
public final class SchedulerManager implements Scheduler {
private final Scheduler scheduler = Scheduler.newScheduler();
private final MpmcUnboundedXaddArrayQueue shutdownTasks = new MpmcUnboundedXaddArrayQueue<>(1024);
@Override
public void process() {
this.scheduler.process();
}
@Override
public void processTick() {
this.scheduler.processTick();
}
@Override
public void processTickEnd() {
this.scheduler.processTickEnd();
}
@Override
public @NotNull Task submitTask(@NotNull Supplier task,
@NotNull ExecutionType executionType) {
return scheduler.submitTask(task, executionType);
}
public void shutdown() {
this.shutdownTasks.drain(Runnable::run);
}
public void buildShutdownTask(@NotNull Runnable runnable) {
this.shutdownTasks.relaxedOffer(runnable);
}
}