Package net.minecraft.util.thread
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 Summary
-
Constructor Summary
Constructors Modifier Constructor Description protected
ThreadExecutor(String name)
-
Method Summary
Modifier and Type Method Description protected void
cancelTasks()
protected abstract boolean
canExecute(R task)
protected abstract R
createTask(Runnable runnable)
void
execute(Runnable runnable)
protected void
executeTask(R task)
String
getName()
int
getTaskCount()
protected abstract Thread
getThread()
boolean
isOnThread()
protected boolean
runTask()
protected void
runTasks()
void
runTasks(BooleanSupplier stopCondition)
void
send(R r)
protected boolean
shouldExecuteAsync()
CompletableFuture<Void>
submit(Runnable task)
<V> CompletableFuture<V>
submit(Supplier<V> task)
void
submitAndJoin(Runnable runnable)
private CompletableFuture<Void>
submitAsync(Runnable runnable)
protected void
waitForTasks()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.minecraft.util.thread.MessageListener
ask, close, method_27918
-
Field Details
-
LOGGER
-
name
-
tasks
-
executionsInProgress
private int executionsInProgress
-
-
Constructor Details
-
ThreadExecutor
-
-
Method Details
-
createTask
-
canExecute
-
isOnThread
public boolean isOnThread() -
getThread
-
shouldExecuteAsync
protected boolean shouldExecuteAsync() -
getTaskCount
public int getTaskCount() -
getName
- Specified by:
getName
in interfaceMessageListener<R extends Runnable>
-
submit
-
submitAsync
-
submit
-
submitAndJoin
-
send
- Specified by:
send
in interfaceMessageListener<R extends Runnable>
-
execute
-
cancelTasks
@Environment(CLIENT) protected void cancelTasks() -
runTasks
protected void runTasks() -
runTask
protected boolean runTask() -
runTasks
-
waitForTasks
protected void waitForTasks() -
executeTask
-