From 9bdb4252e5cacd795af5e06423125a8d741b5df9 Mon Sep 17 00:00:00 2001 From: sithlord48 Date: Tue, 20 May 2025 19:26:33 -0400 Subject: [PATCH] chore: remove goto in EventQueue, instead use a private processEvent method --- src/lib/base/EventQueue.cpp | 12 ++++++++---- src/lib/base/EventQueue.h | 9 +++++++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/src/lib/base/EventQueue.cpp b/src/lib/base/EventQueue.cpp index f8b3e8d4a..71c512f2c 100644 --- a/src/lib/base/EventQueue.cpp +++ b/src/lib/base/EventQueue.cpp @@ -101,10 +101,8 @@ void EventQueue::adoptBuffer(IEventQueueBuffer *buffer) } } -bool EventQueue::getEvent(Event &event, double timeout) +bool EventQueue::processEvent(Event &event, double timeout, Stopwatch &timer) { - Stopwatch timer(true); -retry: // if no events are waiting then handle timers and then wait while (m_buffer->isEmpty()) { // handle timers first @@ -139,7 +137,7 @@ retry: // don't want to fail if client isn't expecting that // so if getEvent() fails with an infinite timeout // then just try getting another event. - goto retry; + processEvent(event, timeout, timer); } return false; @@ -158,6 +156,12 @@ retry: } } +bool EventQueue::getEvent(Event &event, double timeout) +{ + Stopwatch timer(true); + return processEvent(event, timeout, timer); +} + bool EventQueue::dispatchEvent(const Event &event) { void *target = event.getTarget(); diff --git a/src/lib/base/EventQueue.h b/src/lib/base/EventQueue.h index a7101443d..8eb358460 100644 --- a/src/lib/base/EventQueue.h +++ b/src/lib/base/EventQueue.h @@ -58,6 +58,15 @@ private: double getNextTimerTimeout() const; void addEventToBuffer(const Event &event); + //! + //! \brief processEvent Internal event proccessing + //! \param event - event to process + //! \param timeout - Timeout to stop + //! \param timer - StopWatch to use + //! \return true if handled + //! + bool processEvent(Event &event, double timeout, Stopwatch &timer); + private: class Timer {