if (m_timer_list)
{
+ singleLock s(recalcLock);
poll_timeout = timeval_to_usec(m_timer_list.begin()->getNextActivation() - now);
/* if current timer already passed, don't delay infinite. */
if (poll_timeout < 0)
/* when we not processed anything, check timers. */
if (!ret)
{
+ singleLock s(recalcLock);
+
/* process all timers which are ready. first remove them out of the list. */
while ((!m_timer_list.empty()) && (m_timer_list.begin()->getNextActivation() < now))
m_timer_list.begin()->activate();
void eMainloop::addTimeOffset(int offset)
{
- singleLock s(recalcLock);
- for (ePtrList<eTimer>::iterator it = m_timer_list.begin(); it != m_timer_list.end(); ++it )
- it->addTimeOffset(offset);
+ for (ePtrList<eMainloop>::iterator it(eMainloop::existing_loops)
+ ;it != eMainloop::existing_loops.end(); ++it)
+ {
+ singleLock s(it->recalcLock);
+ for (ePtrList<eTimer>::iterator tit = it->m_timer_list.begin(); tit != it->m_timer_list.end(); ++tit )
+ tit->addTimeOffset(offset);
+ }
}
eApplication* eApp = 0;
int loop_level;
void processOneEvent();
int retval;
- int timer_offset;
pthread_mutex_t recalcLock;
public:
- void addTimeOffset(int offset);
+ static void addTimeOffset(int offset);
void addSocketNotifier(eSocketNotifier *sn);
void removeSocketNotifier(eSocketNotifier *sn);
void addTimer(eTimer* e);
static ePtrList<eMainloop> existing_loops;
eMainloop()
- :app_quit_now(0),loop_level(0),retval(0),timer_offset(0)
+ :app_quit_now(0),loop_level(0),retval(0)
{
existing_loops.push_back(this);
pthread_mutex_init(&recalcLock, 0);
gettimeofday(&tnow,0);
tnow.tv_sec=rtc_time;
settimeofday(&tnow,0);
- for (ePtrList<eMainloop>::iterator it(eMainloop::existing_loops)
- ;it != eMainloop::existing_loops.end(); ++it)
- it->addTimeOffset(m_time_difference);
+ eMainloop::addTimeOffset(m_time_difference);
m_time_difference=0;
}
else if ( !m_time_difference )