Skip to content

Commit 36f425b

Browse files
committed
Fix excessive recursion from mailbox
1 parent dc3c379 commit 36f425b

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

src/main/java/org/embeddedt/modernfix/util/SingleThreadedWorkerService.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.embeddedt.modernfix.util;
22

3+
import net.minecraft.util.thread.ProcessorMailbox;
34
import org.jetbrains.annotations.NotNull;
45

56
import java.util.List;
@@ -52,9 +53,13 @@ public boolean awaitTermination(long timeout, @NotNull TimeUnit unit) throws Int
5253
return executorService.awaitTermination(timeout, unit);
5354
}
5455

56+
private static boolean isForcedAsyncCommand(Runnable command) {
57+
return command instanceof ProcessorMailbox<?>;
58+
}
59+
5560
@Override
5661
public void execute(@NotNull Runnable command) {
57-
if (Thread.currentThread() == thread.get()) {
62+
if (!isForcedAsyncCommand(command) && Thread.currentThread() == thread.get()) {
5863
command.run();
5964
} else {
6065
executorService.execute(command);

0 commit comments

Comments
 (0)