Class BlockableEventLoop<R extends Runnable>

java.lang.Object
net.minecraft.util.thread.BlockableEventLoop<R>
All Implemented Interfaces:
AutoCloseable, Executor, ProfilerMeasured, TaskScheduler<R>
Direct Known Subclasses:
ReentrantBlockableEventLoop, ServerChunkCache.MainThreadExecutor, SoundEngineExecutor

public abstract class BlockableEventLoop<R extends Runnable> extends Object implements Executor, TaskScheduler<R>, ProfilerMeasured
  • Field Details

    • BLOCK_TIME_NANOS

      public static final long BLOCK_TIME_NANOS
      See Also:
    • delayedCrash

      private static volatile @Nullable Supplier<CrashReport> delayedCrash
    • propagatesCrashes

      private final boolean propagatesCrashes
    • name

      private final String name
    • LOGGER

      private static final org.slf4j.Logger LOGGER
    • pendingRunnables

      private final Queue<R extends Runnable> pendingRunnables
    • blockingCount

      private int blockingCount
  • Constructor Details

    • BlockableEventLoop

      protected BlockableEventLoop(String name, boolean propagatesCrashes)
  • Method Details

    • shouldRun

      protected abstract boolean shouldRun(R task)
    • isSameThread

      public boolean isSameThread()
    • getRunningThread

      protected abstract Thread getRunningThread()
    • scheduleExecutables

      protected boolean scheduleExecutables()
    • getPendingTasksCount

      public int getPendingTasksCount()
    • name

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

      public <V> CompletableFuture<V> submit(Supplier<V> supplier)
    • submitAsync

      public CompletableFuture<Void> submitAsync(Runnable runnable)
    • submit

      @CheckReturnValue public CompletableFuture<Void> submit(Runnable runnable)
    • executeBlocking

      public void executeBlocking(Runnable runnable)
    • schedule

      public void schedule(R r)
      Specified by:
      schedule in interface TaskScheduler<R extends Runnable>
    • execute

      public void execute(Runnable command)
      Specified by:
      execute in interface Executor
    • executeIfPossible

      public void executeIfPossible(Runnable command)
    • dropAllTasks

      protected void dropAllTasks()
    • runAllTasks

      protected void runAllTasks()
    • shouldRunAllTasks

      protected boolean shouldRunAllTasks()
    • pollTask

      protected boolean pollTask()
    • managedBlock

      public void managedBlock(BooleanSupplier condition)
      Drive the executor until the given BooleanSupplier returns true
    • waitForTasks

      protected void waitForTasks()
    • doRunTask

      protected void doRunTask(R task)
    • profiledMetrics

      public List<MetricSampler> profiledMetrics()
      Specified by:
      profiledMetrics in interface ProfilerMeasured
    • isNonRecoverable

      public static boolean isNonRecoverable(Throwable t)
    • throwDelayedException

      private void throwDelayedException()
    • hasDelayedCrash

      protected boolean hasDelayedCrash()
    • delayCrash

      public void delayCrash(CrashReport crashReport)
    • relayDelayCrash

      public static void relayDelayCrash(CrashReport crashReport)