{
int fd = sn->getFD();
ASSERT(notifiers.find(fd) == notifiers.end());
- notifiers[fd]=sn;
+ ASSERT(new_notifiers.find(fd) == new_notifiers.end());
+ new_notifiers[fd]=sn;
}
void eMainloop::removeSocketNotifier(eSocketNotifier *sn)
{
- for (std::map<int,eSocketNotifier*>::iterator i = notifiers.find(sn->getFD());
- i != notifiers.end();
- ++i)
- if (i->second == sn)
- return notifiers.erase(i);
+ int fd = sn->getFD();
+ std::map<int,eSocketNotifier*>::iterator i(notifiers.find(fd));
+ if (i != notifiers.end())
+ return notifiers.erase(i);
+ i = new_notifiers.find(fd);
+ if (i != new_notifiers.end())
+ return new_notifiers.erase(i);
eFatal("removed socket notifier which is not present");
}
-int eMainloop::processOneEvent(unsigned int user_timeout, PyObject **res, PyObject *additional)
+int eMainloop::processOneEvent(unsigned int user_timeout, PyObject **res, ePyObject additional)
{
int return_reason = 0;
/* get current time */
poll_timeout = user_timeout;
return_reason = 1;
}
-
+
+ for (std::map<int, eSocketNotifier*>::iterator it(new_notifiers.begin()); it != new_notifiers.end();)
+ {
+ notifiers[it->first]=it->second;
+ new_notifiers.erase(it++);
+ }
+
int nativecount=notifiers.size(),
fdcount=nativecount,
ret=0;
{
if (!*res)
*res = PyList_New(0);
- PyObject *it = PyTuple_New(2);
+ ePyObject it = PyTuple_New(2);
PyTuple_SET_ITEM(it, 0, PyInt_FromLong(pfd[i].fd));
PyTuple_SET_ITEM(it, 1, PyInt_FromLong(pfd[i].revents));
PyList_Append(*res, it);
m_timer_list.remove(e);
}
-int eMainloop::iterate(unsigned int user_timeout, PyObject **res, PyObject *dict)
+int eMainloop::iterate(unsigned int user_timeout, PyObject **res, ePyObject dict)
{
int ret = 0;
app_quit_now=false;
}
-PyObject *eMainloop::poll(PyObject *timeout, PyObject *dict)
+PyObject *eMainloop::poll(ePyObject timeout, ePyObject dict)
{
- PyObject *res = 0;
+ PyObject *res=0;
if (app_quit_now)
- {
- Py_INCREF(Py_None);
- return Py_None;
- }
+ Py_RETURN_NONE;
int user_timeout = (timeout == Py_None) ? 0 : PyInt_AsLong(timeout);
iterate(user_timeout, &res, dict);
+ ePyObject ret(res);
- if (!res) /* return empty list on timeout */
- res = PyList_New(0);
+ if (!ret) /* return empty list on timeout */
+ return PyList_New(0);
- return res;
+ return ret;
}
void eMainloop::interruptPoll()