Class ThreadDispatcher<P>

java.lang.Object
net.minestom.server.thread.ThreadDispatcher<P>

public final class ThreadDispatcher<P> extends Object
Used to link chunks into multiple groups. Then executed into a thread pool.
  • Method Details

    • of

      @NotNull public static <P> @NotNull ThreadDispatcher<P> of(@NotNull @NotNull ThreadProvider<P> provider, int threadCount)
    • singleThread

      @NotNull public static <P> @NotNull ThreadDispatcher<P> singleThread()
    • threads

      @NotNull public @Unmodifiable @NotNull List<@NotNull TickThread> threads()
    • updateAndAwait

      public void updateAndAwait(long time)
      Prepares the update by creating the TickThread tasks.
      Parameters:
      time - the tick time in milliseconds
    • refreshThreads

      public void refreshThreads(long nanoTimeout)
      Called at the end of each tick to clear removed entities, refresh the chunk linked to an entity, and chunk threads based on ThreadProvider.findThread(Object).
      Parameters:
      nanoTimeout - max time in nanoseconds to update partitions
    • refreshThreads

      public void refreshThreads()
    • createPartition

      public void createPartition(P partition)
    • deletePartition

      public void deletePartition(P partition)
    • updateElement

      public void updateElement(Tickable tickable, P partition)
    • removeElement

      public void removeElement(Tickable tickable)
    • shutdown

      public void shutdown()
      Shutdowns all the tick threads.

      Action is irreversible.