Skip to content

Commit

Permalink
fix: don't use NEXT_WORKER_ID in Util mixin
Browse files Browse the repository at this point in the history
  • Loading branch information
getchoo committed Dec 12, 2023
1 parent c1337b7 commit 443891b
Showing 1 changed file with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,7 @@ public abstract class UtilMixin {

@Shadow @Final @Mutable
private static ExecutorService IO_WORKER_EXECUTOR;

@Shadow @Final
private static AtomicInteger NEXT_WORKER_ID;


@Shadow
private static void uncaughtExceptionHandler(Thread thread, Throwable throwable) {}

Expand Down Expand Up @@ -75,7 +72,7 @@ private static ExecutorService replWorker(String name) {

return new ForkJoinPool(MathHelper.clamp(select(name, SmoothBoot.config.threadCount.bootstrap,
SmoothBoot.config.threadCount.main), 1, 0x7fff), (forkJoinPool) -> {
String workerName = "Worker-" + name + "-" + NEXT_WORKER_ID.getAndIncrement();
String workerName = "Worker-" + name + "-" + new AtomicInteger(1).getAndIncrement();
SmoothBoot.LOGGER.debug("Initialized " + workerName);

ForkJoinWorkerThread forkJoinWorkerThread = new LoggingForkJoinWorkerThread(forkJoinPool, SmoothBoot.LOGGER);
Expand All @@ -91,7 +88,7 @@ private static ExecutorService replWorker(String name) {
*/
private static ExecutorService replIoWorker() {
return Executors.newCachedThreadPool((runnable) -> {
String workerName = "IO-Worker-" + NEXT_WORKER_ID.getAndIncrement();
String workerName = "IO-Worker-" + new AtomicInteger(1).getAndIncrement();
SmoothBoot.LOGGER.debug("Initialized " + workerName);

Thread thread = new Thread(runnable);
Expand Down

0 comments on commit 443891b

Please sign in to comment.