chore: remove goto in EventQueue, instead use a private processEvent method

This commit is contained in:
sithlord48
2025-05-20 19:26:33 -04:00
committed by Nick Bolton
parent c73729e72e
commit 9bdb4252e5
2 changed files with 17 additions and 4 deletions

View File

@ -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();

View File

@ -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
{