Class ThreadExecutor<R extends Runnable>

java.lang.Object
net.minecraft.util.thread.ThreadExecutor<R>
All Implemented Interfaces:
AutoCloseable, Executor, MessageListener<R>
Direct Known Subclasses:
ReentrantThreadExecutor, ServerChunkManager.MainThreadExecutor, SoundExecutor

public abstract class ThreadExecutor<R extends Runnable>
extends Object
implements MessageListener<R>, Executor
  • Field Details

    • LOGGER

      private static final Logger LOGGER
    • name

      private final String name
    • tasks

      private final Queue<R extends Runnable> tasks
    • executionsInProgress

      private int executionsInProgress
  • Constructor Details

    • ThreadExecutor

      protected ThreadExecutor​(String name)
  • Method Details

    • createTask

      protected abstract R createTask​(Runnable runnable)
    • canExecute

      protected abstract boolean canExecute​(R task)
    • isOnThread

      public boolean isOnThread()
    • getThread

      protected abstract Thread getThread()
    • shouldExecuteAsync

      protected boolean shouldExecuteAsync()
    • getTaskCount

      public int getTaskCount()
    • getName

      public String getName()
      Specified by:
      getName in interface MessageListener<R extends Runnable>
    • submit

      @Environment(CLIENT) public <V> CompletableFuture<V> submit​(Supplier<V> task)
    • submitAsync

      private CompletableFuture<Void> submitAsync​(Runnable runnable)
    • submit

      public CompletableFuture<Void> submit​(Runnable task)
    • submitAndJoin

      public void submitAndJoin​(Runnable runnable)
    • send

      public void send​(R r)
      Specified by:
      send in interface MessageListener<R extends Runnable>
    • execute

      public void execute​(Runnable runnable)
      Specified by:
      execute in interface Executor
    • cancelTasks

      @Environment(CLIENT) protected void cancelTasks()
    • runTasks

      protected void runTasks()
    • runTask

      protected boolean runTask()
    • runTasks

      public void runTasks​(BooleanSupplier stopCondition)
    • waitForTasks

      protected void waitForTasks()
    • executeTask

      protected void executeTask​(R task)