generated from MrSphay/codex-agent-repository-kit
Decompile upstream Explosion Overhaul 0.2.3.0
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Decompiled with CFR 0.152.
|
||||
*/
|
||||
package com.vinlanx.explosionoverhaul.client;
|
||||
|
||||
import java.util.Queue;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
public final class SoundEngineAudioQueue {
|
||||
private static final Queue<Runnable> QUEUE = new ConcurrentLinkedQueue<Runnable>();
|
||||
|
||||
private SoundEngineAudioQueue() {
|
||||
}
|
||||
|
||||
public static void enqueueAudio(Runnable task) {
|
||||
if (task == null) {
|
||||
return;
|
||||
}
|
||||
if (SoundEngineAudioQueue.isSoundThread()) {
|
||||
try {
|
||||
task.run();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
SoundEngineAudioQueue.drainNow();
|
||||
} else {
|
||||
QUEUE.offer(task);
|
||||
}
|
||||
}
|
||||
|
||||
public static void drainNow() {
|
||||
Runnable next;
|
||||
if (!SoundEngineAudioQueue.isSoundThread()) {
|
||||
return;
|
||||
}
|
||||
while ((next = QUEUE.poll()) != null) {
|
||||
try {
|
||||
next.run();
|
||||
}
|
||||
catch (Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isSoundThread() {
|
||||
return "Sound engine".equals(Thread.currentThread().getName());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user