Dont deadlock

This commit is contained in:
mcrcortex
2025-06-09 20:26:19 +10:00
parent 5b752d3f87
commit f73413e7c0

View File

@@ -53,12 +53,18 @@ public class SectionSavingService {
//Hard limit the save count to prevent OOM //Hard limit the save count to prevent OOM
if (this.getTaskCount() > 5_000) { if (this.getTaskCount() > 5_000) {
while (this.getTaskCount() > 5_000) { //wait a bit
try { try {
Thread.sleep(10); Thread.sleep(10);
} catch (InterruptedException e) { } catch (InterruptedException e) {
throw new RuntimeException(e); throw new RuntimeException(e);
} }
//If we are still full, process entries in the queue ourselves instead of waiting for the service
while (this.getTaskCount() > 5_000 && this.threads.isAlive()) {
if (!this.threads.steal()) {
break;
}
this.processJob();
} }
} }