Skip to content

Commit

Permalink
Merge pull request #19207 from hrydgard/sdl-avoid-spinning
Browse files Browse the repository at this point in the history
SDL: Switch to SDL_WaitEventTimeout instead of SDL_PollEvent when possible.
  • Loading branch information
hrydgard authored May 28, 2024
2 parents 7d80f83 + 2c50f82 commit a851e82
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions SDL/SDLMain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1420,10 +1420,12 @@ int main(int argc, char *argv[]) {
bool waitOnExit = g_Config.iGPUBackend == (int)GPUBackend::OPENGL;

if (!mainThreadIsRender) {
// We should only be a message pump
// Vulkan mode uses this.
// We should only be a message pump. This allows for lower latency
// input events, and so on.
while (true) {
SDL_Event event;
while (SDL_PollEvent(&event)) {
while (SDL_WaitEventTimeout(&event, 100)) {
ProcessSDLEvent(window, event, &inputTracker);
}
if (g_QuitRequested || g_RestartRequested)
Expand Down

0 comments on commit a851e82

Please sign in to comment.