X-Git-Url: https://git.cweiske.de/enigma2.git/blobdiff_plain/5518d56f51a8951cc7cea96ee1782ba470380ddc..f0f30b07354683b86bcb10d510f54f459fa8ca37:/lib/base/ebase.cpp diff --git a/lib/base/ebase.cpp b/lib/base/ebase.cpp index e53aa745..effd7250 100644 --- a/lib/base/ebase.cpp +++ b/lib/base/ebase.cpp @@ -116,6 +116,16 @@ void eTimer::addTimeOffset( int offset ) // mainloop ePtrList eMainloop::existing_loops; +eMainloop::~eMainloop() +{ + existing_loops.remove(this); + pthread_mutex_destroy(&recalcLock); + for (std::map::iterator it(notifiers.begin());it != notifiers.end();++it) + it->second->stop(); + while(m_timer_list.begin() != m_timer_list.end()) + m_timer_list.begin()->stop(); +} + void eMainloop::addSocketNotifier(eSocketNotifier *sn) { int fd = sn->getFD(); @@ -197,12 +207,17 @@ int eMainloop::processOneEvent(unsigned int twisted_timeout, PyObject **res, ePy } } + m_is_idle = 1; + if (this == eApp) + { Py_BEGIN_ALLOW_THREADS ret = ::poll(pfd, fdcount, poll_timeout); Py_END_ALLOW_THREADS - else + } else ret = ::poll(pfd, fdcount, poll_timeout); + + m_is_idle = 0; /* ret > 0 means that there are some active poll entries. */ if (ret > 0) @@ -289,11 +304,13 @@ int eMainloop::iterate(unsigned int twisted_timeout, PyObject **res, ePyObject d { timeval now, timeout; gettimeofday(&now, 0); - m_twisted_timer -= time_offset; + 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) );