forked from StarOpenSource/Engine
Replace Thread#sleep calls with Thread#onSpinWait
This commit is contained in:
parent
0d4fa85c91
commit
a3ca81498e
2 changed files with 8 additions and 11 deletions
|
@ -137,10 +137,9 @@ public final class Logger {
|
||||||
flushLogMessages();
|
flushLogMessages();
|
||||||
|
|
||||||
// Sleep for whatever has been configured
|
// Sleep for whatever has been configured
|
||||||
try {
|
long sleepDuration = System.currentTimeMillis() + EngineConfiguration.getInstance().getLoggerPollingSpeed();
|
||||||
//noinspection BusyWait
|
while (System.currentTimeMillis() < sleepDuration)
|
||||||
Thread.sleep(EngineConfiguration.getInstance().getLoggerPollingSpeed());
|
Thread.onSpinWait();
|
||||||
} catch (Exception ignored) {}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -113,12 +113,10 @@ public abstract class ApiManagementClass {
|
||||||
splitDeltaTime.add(renderTime + sleepDuration);
|
splitDeltaTime.add(renderTime + sleepDuration);
|
||||||
|
|
||||||
// Busy wait unless V-Sync is enabled
|
// Busy wait unless V-Sync is enabled
|
||||||
if (WindowingSubsystemConfiguration.getInstance().getVsyncMode() == VsyncMode.OFF)
|
if (WindowingSubsystemConfiguration.getInstance().getVsyncMode() == VsyncMode.OFF && WindowingSubsystemConfiguration.getInstance().getMaximumFramesPerSecond() >= 1) {
|
||||||
try {
|
sleepDuration += System.currentTimeMillis();
|
||||||
//noinspection BusyWait // true, true, but there's no other way to do it
|
while (System.currentTimeMillis() < sleepDuration)
|
||||||
Thread.sleep(sleepDuration);
|
Thread.onSpinWait();
|
||||||
} catch (InterruptedException exception) {
|
|
||||||
logger.crash("Rendering loop got interrupted. This is unsupported behaviour", exception);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Calculate delta time and frame count every second
|
// Calculate delta time and frame count every second
|
||||||
|
|
Loading…
Reference in a new issue