mirror of
https://github.com/Winds-Studio/Leaf.git
synced 2025-12-21 07:59:26 +00:00
* Region based comment helper functions * (Region based comment) Dont save entity * (Region based comment) Pufferfish DAB * (Region based comment) Cache EntityType * (Region based comment) Cache EntityType * (Region based comment) Pufferfish EntityTTL * (Region based comment) Faster sequence * (Region based comment) FastRNG * (Region based comment) 0042 * (Region based comment) 0721 * (Region based comment) 0009 * (Region based comment) V1rtUal tHReaD * (Region based comment) ZSSM * [ci skip] (Region based comment) 0079 * [ci skip] (Region based comment) 0089 0090 * [ci skip] (Region based comment) 0049 0118 0138 * [ci skip] (Region based comment) 0006 0017 0018 0080 0081 * [ci skip] (Region based comment) 0019 0038 0059 0108 0117 0127 * ALL PATCHES ARE DONE * [ci skip] NZDD
47 lines
2.8 KiB
Diff
47 lines
2.8 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: HaHaWTH <102713261+HaHaWTH@users.noreply.github.com>
|
|
Date: Fri, 25 Oct 2024 02:27:21 +0800
|
|
Subject: [PATCH] Virtual thread for chat executor
|
|
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
index a6d6e3ad434420223178f813953d9c53db26034a..2445d549fbf972620f2cc13860f826562ff3f4d0 100644
|
|
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
|
@@ -2882,7 +2882,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
|
}
|
|
|
|
public final java.util.concurrent.ExecutorService chatExecutor = java.util.concurrent.Executors.newCachedThreadPool(
|
|
- new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper
|
|
+ new com.google.common.util.concurrent.ThreadFactoryBuilder().setDaemon(true).setNameFormat("Async Chat Thread - #%d").setThreadFactory(org.dreeam.leaf.config.modules.opt.VT4ChatExecutor.enabled ? Thread.ofVirtual().factory() : java.util.concurrent.Executors.defaultThreadFactory()).setUncaughtExceptionHandler(new net.minecraft.DefaultUncaughtExceptionHandlerWithName(net.minecraft.server.MinecraftServer.LOGGER)).build()); // Paper // Leaf - Virtual thread for chatExecutor
|
|
|
|
public final ChatDecorator improvedChatDecorator = new io.papermc.paper.adventure.ImprovedChatDecorator(this); // Paper - adventure
|
|
public ChatDecorator getChatDecorator() {
|
|
diff --git a/src/main/java/org/dreeam/leaf/config/modules/opt/VT4ChatExecutor.java b/src/main/java/org/dreeam/leaf/config/modules/opt/VT4ChatExecutor.java
|
|
new file mode 100644
|
|
index 0000000000000000000000000000000000000000..964c20331661774b4d8866f9eef50e60dbf3069b
|
|
--- /dev/null
|
|
+++ b/src/main/java/org/dreeam/leaf/config/modules/opt/VT4ChatExecutor.java
|
|
@@ -0,0 +1,21 @@
|
|
+package org.dreeam.leaf.config.modules.opt;
|
|
+
|
|
+import org.dreeam.leaf.config.ConfigModules;
|
|
+import org.dreeam.leaf.config.EnumConfigCategory;
|
|
+
|
|
+public class VT4ChatExecutor extends ConfigModules {
|
|
+
|
|
+ public String getBasePath() {
|
|
+ return EnumConfigCategory.PERF.getBaseKeyName();
|
|
+ }
|
|
+
|
|
+ public static boolean enabled = true;
|
|
+
|
|
+ @Override
|
|
+ public void onLoaded() {
|
|
+ enabled = config.getBoolean(getBasePath() + ".use-virtual-thread-for-async-chat-executor", enabled,
|
|
+ config.pickStringRegionBased(
|
|
+ "Use the new Virtual Thread introduced in JDK 21 for Async Chat Executor.",
|
|
+ "是否为异步聊天线程使用虚拟线程."));
|
|
+ }
|
|
+}
|