From 44a321b47037ed6c51593c6d82d9397330766d63 Mon Sep 17 00:00:00 2001 From: IoyoCode Date: Tue, 19 Sep 2023 08:33:45 +0100 Subject: [PATCH] fix(cpu): disabled reset thread as it's not doing much --- .../utils/rest/ratelimit/Bucket.java | 46 +++++++++---------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/main/java/com/seailz/discordjar/utils/rest/ratelimit/Bucket.java b/src/main/java/com/seailz/discordjar/utils/rest/ratelimit/Bucket.java index de75b654..6e4b3d03 100644 --- a/src/main/java/com/seailz/discordjar/utils/rest/ratelimit/Bucket.java +++ b/src/main/java/com/seailz/discordjar/utils/rest/ratelimit/Bucket.java @@ -31,29 +31,29 @@ public Bucket(String id, int limit, int remaining, long reset, double resetAfter this.resetAfter = new AtomicLong(resetAfterMillis); this.debug = debug; // Start the reset thread - new Thread(() -> { - while (true) { - if (remaining != 0) { - continue; - } - long currentReset = atomicReset.get(); - long currentTime = System.currentTimeMillis(); - - if (currentReset > currentTime) { - try { - Thread.sleep(currentReset - currentTime); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } - if (atomicReset.compareAndSet(currentReset, System.currentTimeMillis() + resetAfterMillis)) { - if (debug) { - System.out.println("Resetting requests for " + id); - } - reset(); // Reset the bucket only if the currentReset is still the same as the one we fetched above. - } - } - }, "djar--bucket-reset").start(); +// new Thread(() -> { +// while (true) { +// if (remaining != 0) { +// continue; +// } +// long currentReset = atomicReset.get(); +// long currentTime = System.currentTimeMillis(); +// +// if (currentReset > currentTime) { +// try { +// Thread.sleep(currentReset - currentTime); +// } catch (InterruptedException e) { +// e.printStackTrace(); +// } +// } +// if (atomicReset.compareAndSet(currentReset, System.currentTimeMillis() + resetAfterMillis)) { +// if (debug) { +// System.out.println("Resetting requests for " + id); +// } +// reset(); // Reset the bucket only if the currentReset is still the same as the one we fetched above. +// } +// } +// }, "djar--bucket-reset").start(); } public synchronized Bucket update(int limit, int remaining, double reset, float resetAfter) {