SoundEngineExecutor.java
net.minecraft.client.sounds.SoundEngineExecutor
信息
- 全限定名:net.minecraft.client.sounds.SoundEngineExecutor
- 类型:public class
- 包:net.minecraft.client.sounds
- 源码路径:src/main/java/net/minecraft/client/sounds/SoundEngineExecutor.java
- 起始行号:L11
- 继承:BlockableEventLoop
- 职责:
TODO
字段/常量
-
thread- 类型:
Thread - 修饰符:
private - 源码定位:
L12 - 说明:
TODO
- 类型:
-
shutdown- 类型:
boolean - 修饰符:
private volatile - 源码定位:
L13 - 说明:
TODO
- 类型:
内部类/嵌套类型
- 无
构造器
public SoundEngineExecutor() @ L15
- 构造器名:SoundEngineExecutor
- 源码定位:L15
- 修饰符:public
参数:
- 无
说明:
TODO
方法
下面的方法块按源码顺序生成。
private Thread createThread() @ L19
- 方法名:createThread
- 源码定位:L19
- 返回类型:Thread
- 修饰符:private
参数:
- 无
说明:
TODO
public Runnable wrapRunnable(Runnable runnable) @ L30
- 方法名:wrapRunnable
- 源码定位:L30
- 返回类型:Runnable
- 修饰符:public
参数:
- runnable: Runnable
说明:
TODO
public void schedule(Runnable runnable) @ L35
- 方法名:schedule
- 源码定位:L35
- 返回类型:void
- 修饰符:public
参数:
- runnable: Runnable
说明:
TODO
protected boolean shouldRun(Runnable task) @ L42
- 方法名:shouldRun
- 源码定位:L42
- 返回类型:boolean
- 修饰符:protected
参数:
- task: Runnable
说明:
TODO
protected Thread getRunningThread() @ L47
- 方法名:getRunningThread
- 源码定位:L47
- 返回类型:Thread
- 修饰符:protected
参数:
- 无
说明:
TODO
private void run() @ L52
- 方法名:run
- 源码定位:L52
- 返回类型:void
- 修饰符:private
参数:
- 无
说明:
TODO
protected void waitForTasks() @ L58
- 方法名:waitForTasks
- 源码定位:L58
- 返回类型:void
- 修饰符:protected
参数:
- 无
说明:
TODO
public void shutDown() @ L63
- 方法名:shutDown
- 源码定位:L63
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
public void startUp() @ L75
- 方法名:startUp
- 源码定位:L75
- 返回类型:void
- 修饰符:public
参数:
- 无
说明:
TODO
代码
@OnlyIn(Dist.CLIENT)
public class SoundEngineExecutor extends BlockableEventLoop<Runnable> {
private Thread thread = this.createThread();
private volatile boolean shutdown;
public SoundEngineExecutor() {
super("Sound executor", false);
}
private Thread createThread() {
Thread thread = new Thread(this::run);
thread.setDaemon(true);
thread.setName("Sound engine");
thread.setUncaughtExceptionHandler(
(t, e) -> Minecraft.getInstance().delayCrash(CrashReport.forThrowable(e, "Uncaught exception on thread: " + t.getName()))
);
thread.start();
return thread;
}
@Override
public Runnable wrapRunnable(Runnable runnable) {
return runnable;
}
@Override
public void schedule(Runnable runnable) {
if (!this.shutdown) {
super.schedule(runnable);
}
}
@Override
protected boolean shouldRun(Runnable task) {
return !this.shutdown;
}
@Override
protected Thread getRunningThread() {
return this.thread;
}
private void run() {
while (!this.shutdown) {
this.managedBlock(() -> this.shutdown);
}
}
@Override
protected void waitForTasks() {
LockSupport.park("waiting for tasks");
}
public void shutDown() {
this.shutdown = true;
this.dropAllTasks();
this.thread.interrupt();
try {
this.thread.join();
} catch (InterruptedException var2) {
Thread.currentThread().interrupt();
}
}
public void startUp() {
this.shutdown = false;
this.thread = this.createThread();
}
}引用的其他类
-
- 引用位置:
方法调用 - 关联成员:
CrashReport.forThrowable()
- 引用位置:
-
- 引用位置:
方法调用 - 关联成员:
Minecraft.getInstance()
- 引用位置:
-
- 引用位置:
继承
- 引用位置: