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
-
Method Summary
Modifier and TypeMethodDescriptionvoid
createPartition
(P partition) void
deletePartition
(P partition) static <P> @NotNull ThreadDispatcher
<P> of
(@NotNull ThreadProvider<P> provider, int threadCount) void
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)
.void
removeElement
(Tickable tickable) void
shutdown()
Shutdowns all thetick threads
.static <P> @NotNull ThreadDispatcher
<P> @Unmodifiable @NotNull List
<@NotNull TickThread> threads()
void
updateAndAwait
(long time) Prepares the update by creating theTickThread
tasks.void
updateElement
(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 theTickThread
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 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.
-