Package net.minestom.server.thread
Class ThreadDispatcher<P>
java.lang.Object
net.minestom.server.thread.ThreadDispatcher<P>
Used to link chunks into multiple groups.
Then executed into a thread pool.
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionvoidcreatePartition(P partition) voiddeletePartition(P partition) static <P> @NotNull ThreadDispatcher<P> of(@NotNull ThreadProvider<P> provider, int threadCount) voidvoidrefreshThreads(long nanoTimeout) Called at the end of each tick to clear removed entities, refresh the chunk linked to an entity, and chunk threads based onThreadProvider.findThread(Object).voidremoveElement(Tickable tickable) voidshutdown()Shutdowns all thetick threads.static <P> @NotNull ThreadDispatcher<P> @Unmodifiable @NotNull List<@NotNull TickThread> threads()voidupdateAndAwait(long time) Prepares the update by creating theTickThreadtasks.voidupdateElement(Tickable tickable, P partition)
-
Method Details
-
of
@NotNull public static <P> @NotNull ThreadDispatcher<P> of(@NotNull @NotNull ThreadProvider<P> provider, int threadCount) -
singleThread
-
threads
-
updateAndAwait
public void updateAndAwait(long time) Prepares the update by creating theTickThreadtasks.- 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 onThreadProvider.findThread(Object).- Parameters:
nanoTimeout- max time in nanoseconds to update partitions
-
refreshThreads
public void refreshThreads() -
createPartition
-
deletePartition
-
updateElement
-
removeElement
-
shutdown
public void shutdown()Shutdowns all thetick threads.Action is irreversible.
-