1
0
mirror of https://github.com/SquidDev-CC/CC-Tweaked synced 2025-09-05 11:57:56 +00:00

Fix several issues with the web emulator

- Bump TeaVM version to fix issues with locales and our "export"
   generation.
 - Fix TComputerThread not requeuing correctly.
This commit is contained in:
Jonathan Coates
2023-11-15 13:12:31 +00:00
parent b343c01216
commit f8b7422294
4 changed files with 14 additions and 4 deletions

View File

@@ -28,6 +28,7 @@ public class TComputerThread implements ComputerScheduler {
private static final ArrayDeque<ExecutorImpl> executors = new ArrayDeque<>();
private static final TimerHandler callback = TComputerThread::workOnce;
private static boolean enqueued;
public TComputerThread(int threads) {
}
@@ -38,6 +39,8 @@ public class TComputerThread implements ComputerScheduler {
}
private static void workOnce() {
enqueued = false;
var executor = executors.poll();
if (executor == null) throw new IllegalStateException("Working, but executor is null");
@@ -50,7 +53,14 @@ public class TComputerThread implements ComputerScheduler {
}
executor.afterWork();
if (!executors.isEmpty()) Callbacks.setImmediate(callback);
if (!executors.isEmpty()) enqueue();
}
private static void enqueue() {
if (enqueued) return;
enqueued = true;
Callbacks.setImmediate(callback);
}
@Override
@@ -75,8 +85,8 @@ public class TComputerThread implements ComputerScheduler {
if (onQueue) return;
onQueue = true;
if (executors.isEmpty()) Callbacks.setImmediate(callback);
executors.add(this);
enqueue();
}
void beforeWork() {