Commit 8e3e205c authored by Denis Bilenko's avatar Denis Bilenko

core: add active_event

parent 81872195
......@@ -65,6 +65,7 @@ cdef extern from "event.h":
int event_dispatch() nogil
int event_loop(int loop) nogil
int event_pending(event_t *ev, short, timeval *tv)
void event_active(event_t *ev, int res, short ncalls)
int EVLOOP_ONCE
int EVLOOP_NONBLOCK
......@@ -287,6 +288,20 @@ cdef class signal(event):
self.add(-1)
cdef class active_event(event):
"""An event that is scheduled to run in _this_ loop iteration"""
def __init__(self, callback, *args, **kwargs):
self._callback = callback
self._arg = (args, kwargs)
evtimer_set(&self.ev, __simple_handler, <void*>self)
Py_INCREF(self)
event_active(&self.ev, EV_TIMEOUT, 1)
def add(self, timeout=-1):
raise NotImplementedError
def init():
"""Initialize event queue."""
event_init()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment