chore: remove goto in EventQueue, instead use a private processEvent method
This commit is contained in:
parent
c73729e72e
commit
9bdb4252e5
2 changed files with 17 additions and 4 deletions
|
|
@ -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
|
// if no events are waiting then handle timers and then wait
|
||||||
while (m_buffer->isEmpty()) {
|
while (m_buffer->isEmpty()) {
|
||||||
// handle timers first
|
// handle timers first
|
||||||
|
|
@ -139,7 +137,7 @@ retry:
|
||||||
// don't want to fail if client isn't expecting that
|
// don't want to fail if client isn't expecting that
|
||||||
// so if getEvent() fails with an infinite timeout
|
// so if getEvent() fails with an infinite timeout
|
||||||
// then just try getting another event.
|
// then just try getting another event.
|
||||||
goto retry;
|
processEvent(event, timeout, timer);
|
||||||
}
|
}
|
||||||
return false;
|
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)
|
bool EventQueue::dispatchEvent(const Event &event)
|
||||||
{
|
{
|
||||||
void *target = event.getTarget();
|
void *target = event.getTarget();
|
||||||
|
|
|
||||||
|
|
@ -58,6 +58,15 @@ private:
|
||||||
double getNextTimerTimeout() const;
|
double getNextTimerTimeout() const;
|
||||||
void addEventToBuffer(const Event &event);
|
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:
|
private:
|
||||||
class Timer
|
class Timer
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue