-
Notifications
You must be signed in to change notification settings - Fork 1
/
simple.pxi
75 lines (58 loc) · 2.41 KB
/
simple.pxi
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
cdef class read(event):
"""read(handle, callback, *args) -> event object
Simplified event interface:
Create a new read event, and add it to the event queue.
Arguments:
handle -- file handle, descriptor, or socket
callback -- user callback with (*args) prototype, which can return
a non-None value to be rescheduled
*args -- optional callback arguments
"""
def __init__(self, handle, callback, *args):
event.__init__(self, callback, args, EV_READ, handle, simple=1)
self.args = args # XXX - incref
self.add()
cdef class write(event):
"""write(handle, callback, *args) -> event object
Simplified event interface:
Create a new write event, and add it to the event queue.
Arguments:
handle -- file handle, descriptor, or socket
callback -- user callback with (*args) prototype, which can return
a non-None value to be rescheduled
*args -- optional callback arguments
"""
def __init__(self, handle, callback, *args):
event.__init__(self, callback, args, EV_WRITE, handle, simple=1)
self.args = args # XXX - incref
self.add()
cdef class signal(event):
"""signal(sig, callback, *args) -> event object
Simplified event interface:
Create a new signal event, and add it to the event queue.
XXX - persistent event is added with EV_PERSIST, like signal_set()
Arguments:
sig -- signal number
callback -- user callback with (*args) prototype, which can return
a non-None value to be rescheduled
*args -- optional callback arguments
"""
def __init__(self, sig, callback, *args):
event.__init__(self, callback, args, EV_SIGNAL|EV_PERSIST,
sig, simple=1)
self.args = args # XXX - incref
self.add()
cdef class timeout(event):
"""timeout(secs, callback, *args) -> event object
Simplified event interface:
Create a new timer event, and add it to the event queue.
Arguments:
secs -- event timeout in seconds
callback -- user callback with (*args) prototype, which can return
a non-None value to be rescheduled
*args -- optional callback arguments
"""
def __init__(self, secs, callback, *args):
event.__init__(self, callback, args, simple=1)
self.args = args # XXX - incref
self.add(secs)