Fix excessive recursion from mailbox
This commit is contained in:
parent
dc3c379049
commit
36f425b8cd
|
|
@ -1,5 +1,6 @@
|
||||||
package org.embeddedt.modernfix.util;
|
package org.embeddedt.modernfix.util;
|
||||||
|
|
||||||
|
import net.minecraft.util.thread.ProcessorMailbox;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
@ -52,9 +53,13 @@ public class SingleThreadedWorkerService extends AbstractExecutorService {
|
||||||
return executorService.awaitTermination(timeout, unit);
|
return executorService.awaitTermination(timeout, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static boolean isForcedAsyncCommand(Runnable command) {
|
||||||
|
return command instanceof ProcessorMailbox<?>;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(@NotNull Runnable command) {
|
public void execute(@NotNull Runnable command) {
|
||||||
if (Thread.currentThread() == thread.get()) {
|
if (!isForcedAsyncCommand(command) && Thread.currentThread() == thread.get()) {
|
||||||
command.run();
|
command.run();
|
||||||
} else {
|
} else {
|
||||||
executorService.execute(command);
|
executorService.execute(command);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user