+
+ /* TODO: this code just became ugly. fix that. */
+ do
+ {
+ if (m_interrupt_requested)
+ {
+ m_interrupt_requested = 0;
+ return 0;
+ }
+
+ if (app_quit_now)
+ return -1;
+
+ int to = 0;
+ if (twisted_timeout)
+ {
+ timeval now, timeout;
+ gettimeofday(&now, 0);
+ m_twisted_timer += time_offset; // apply pending offset
+ if (m_twisted_timer<=now) // timeout
+ return 0;
+ timeout = m_twisted_timer - now;
+ to = timeout.tv_sec * 1000 + timeout.tv_usec / 1000;
+ // remove pending offset .. it is re-applied in next call of processOneEvent.. applyTimeOffset
+ m_twisted_timer -= time_offset;
+ }
+ ret = processOneEvent(to, res, dict);
+ } while ( !ret && !(res && *res) );
+
+ return ret;
+}
+
+int eMainloop::runLoop()
+{
+ while (!app_quit_now)
+ iterate();