Attempted last resort fix for thread pool

This commit is contained in:
mcrcortex
2024-08-07 02:18:06 +10:00
parent 395112fc40
commit 0135c63b88

View File

@@ -96,8 +96,21 @@ public class ServiceThreadPool {
} }
int attempts = 50; int attempts = 50;
outer:
while (true) { while (true) {
if (attempts-- == 0) { if (attempts-- == 0) {
for (var service : this.serviceSlices) {
//Run the job
if (!service.doRun(threadId)) {
//Didnt consume the job, find a new job
continue;
}
//Consumed a job from the service, decrease weight by the amount
if (this.totalJobWeight.addAndGet(-service.weightPerJob)<0) {
throw new IllegalStateException("Total job weight is negative");
}
break outer;
}
throw new IllegalStateException("All attempts at executing a job failed! something critically wrong has occurred"); throw new IllegalStateException("All attempts at executing a job failed! something critically wrong has occurred");
} }
seed = (seed ^ seed >>> 30) * -4658895280553007687L; seed = (seed ^ seed >>> 30) * -4658895280553007687L;