The update loop is currently scheduled by an ExecutorService, which is known to be not very precise in its cyclic timing.
Therefore I would like to propose another solution for scheduling, which I currently use to avoid or at least reduce issues like polling errors or timeouts e.g. mentioned in this discussion.
Scheduling is implemented like this:
long sleep_interval_ns;
if (LOCKSTEP_ENABLED) {`
sleep_interval_ns = (long)(sleepInterval / speedFactor / checkFactor)*1000;
} else {
sleep_interval_ns = sleepInterval*1000;
}
Thread loop = new Thread(() -> {
long wait;
while(!shutdown) {
wait = System.nanoTime();
this.run();
LockSupport.parkNanos(sleep_interval_ns - (System.nanoTime() - wait));
}
});
loop.setPriority(Thread.MAX_PRIORITY);
loop.start();
On OSX this turned out to be much more stable although it is not solving the problem completely.
The update loop is currently scheduled by an ExecutorService, which is known to be not very precise in its cyclic timing.
Therefore I would like to propose another solution for scheduling, which I currently use to avoid or at least reduce issues like polling errors or timeouts e.g. mentioned in this discussion.
Scheduling is implemented like this:
On OSX this turned out to be much more stable although it is not solving the problem completely.