From b5f6ada4aea1d5235ec89af508336e092f5ce002 Mon Sep 17 00:00:00 2001 From: Camotoy <20743703+DoctorMacc@users.noreply.github.com> Date: Tue, 1 Sep 2020 13:30:40 -0400 Subject: [PATCH] ScoreboardUpdater: Quick fix to lessen CPU usage (#1238) This prevents one/multiple CPU cores from taking up 100% usage. A better, permanent fix will replace this in the coming days. --- .../org/geysermc/connector/scoreboard/ScoreboardUpdater.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/connector/src/main/java/org/geysermc/connector/scoreboard/ScoreboardUpdater.java b/connector/src/main/java/org/geysermc/connector/scoreboard/ScoreboardUpdater.java index ee38cecd9..3812fb141 100644 --- a/connector/src/main/java/org/geysermc/connector/scoreboard/ScoreboardUpdater.java +++ b/connector/src/main/java/org/geysermc/connector/scoreboard/ScoreboardUpdater.java @@ -31,6 +31,7 @@ import org.geysermc.connector.network.session.GeyserSession; import org.geysermc.connector.network.session.cache.WorldCache; import org.geysermc.connector.utils.LanguageUtils; +import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicInteger; public class ScoreboardUpdater extends Thread { @@ -61,7 +62,7 @@ public class ScoreboardUpdater extends Thread { @Override public void run() { - while (!session.isClosed()) { + if (!session.isClosed()) { long currentTime = System.currentTimeMillis(); // reset score-packets per second every second @@ -99,6 +100,8 @@ public class ScoreboardUpdater extends Thread { } } } + + session.getConnector().getGeneralThreadPool().schedule(this, 50, TimeUnit.MILLISECONDS); } }