mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-20 23:49:31 +00:00
* uwu * reorder * Change author * Sync upstream * Lithium: equipment tracking * Faster CraftServer#getworlds list creation Co-Authored-By: Kobe ⑧ <102713261+HaHaWTH@users.noreply.github.com>
90 lines
3.7 KiB
Diff
90 lines
3.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Taiyou06 <kaandindar21@gmail.com>
|
|
Date: Fri, 8 Nov 2024 00:54:42 +0100
|
|
Subject: [PATCH] Use MCUtil.asyncExecutor for MAIN_WORKER_EXECUTOR
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
|
|
index 815253d03b85a7a476c1efdeca9496fd64afc137..bb4c9bbebaefe9a0c7d213e9b2b07308e684dc7c 100644
|
|
--- a/src/main/java/net/minecraft/Util.java
|
|
+++ b/src/main/java/net/minecraft/Util.java
|
|
@@ -179,7 +179,46 @@ public class Util {
|
|
if (i <= 0) {
|
|
executorService = MoreExecutors.newDirectExecutorService();
|
|
} else {
|
|
- executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
|
|
+ //executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<>(), target -> new io.papermc.paper.util.ServerWorkerThread(target, s, priorityModifier));
|
|
+ // JettPack start
|
|
+ executorService = Integer.getInteger("Paper.WorkerThreadCount", i) <= 0 ? MoreExecutors.newDirectExecutorService() : new java.util.concurrent.AbstractExecutorService(){
|
|
+ private volatile boolean shutdown = false;
|
|
+
|
|
+ @Override
|
|
+ public final List<Runnable> shutdownNow() {
|
|
+ this.shutdown = true;
|
|
+ return java.util.Collections.emptyList();
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final void shutdown() {
|
|
+ this.shutdown = true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final boolean isShutdown() {
|
|
+ return this.shutdown;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final boolean isTerminated() {
|
|
+ return this.shutdown;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final boolean awaitTermination(long l2, TimeUnit timeUnit) throws InterruptedException {
|
|
+ if (!this.shutdown) {
|
|
+ throw new UnsupportedOperationException();
|
|
+ }
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final void execute(Runnable runnable) {
|
|
+ io.papermc.paper.util.MCUtil.asyncExecutor.execute(new org.dreeam.leaf.util.ServerWorkerWrapper(runnable));
|
|
+ }
|
|
+ };
|
|
+ // JettPack end
|
|
}
|
|
/*
|
|
@Override
|
|
diff --git a/src/main/java/org/dreeam/leaf/util/ServerWorkerWrapper.java b/src/main/java/org/dreeam/leaf/util/ServerWorkerWrapper.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..4467dc92f0fb1a62736aa2e9e37d74d493a5dab7
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/util/ServerWorkerWrapper.java
|
|
@@ -0,0 +1,24 @@
|
|
+package org.dreeam.leaf.util;
|
|
+
|
|
+import com.google.common.base.Preconditions;
|
|
+import net.minecraft.Util;
|
|
+
|
|
+public final class ServerWorkerWrapper implements Runnable {
|
|
+ private final Runnable internalRunnable;
|
|
+
|
|
+ public ServerWorkerWrapper(Runnable runnable) {
|
|
+ this.internalRunnable = Preconditions.checkNotNull(runnable, "internalRunnable");
|
|
+ }
|
|
+
|
|
+ @Override
|
|
+ public final void run() {
|
|
+ try {
|
|
+ this.internalRunnable.run();
|
|
+ return;
|
|
+ }
|
|
+ catch (Throwable throwable) {
|
|
+ Util.onThreadException(Thread.currentThread(), throwable);
|
|
+ return;
|
|
+ }
|
|
+ }
|
|
+}
|
|
\ No newline at end of file
|