39
|
1 |
"""
|
|
2 |
Core `struct event` type.
|
|
3 |
"""
|
|
4 |
|
|
5 |
cimport qmsk.net.lib.event2.lib as lib
|
|
6 |
|
|
7 |
# internal helper method for handling timeout arguments
|
|
8 |
cdef lib.timeval* build_timeout (lib.timeval *tv, object timeout = ?) except? <lib.timeval *>-1
|
|
9 |
|
|
10 |
cdef class event :
|
|
11 |
"""
|
|
12 |
Create a new event object with the given parameters.
|
|
13 |
|
|
14 |
An event tracks a single OS file descriptor with some set of events (EV_READ/EV_WRITE) and an optional timeout.
|
|
15 |
|
|
16 |
An event is associated with some event_base, which handles the event mechanism.
|
|
17 |
|
|
18 |
Arguments:
|
|
19 |
base - event_base to use for this event
|
|
20 |
fd - OS file descriptor to watch, or -1
|
|
21 |
events - bitmask of EV_* flags that represents the events to wait for
|
|
22 |
|
|
23 |
When the event fires, it will "call" this event object, so __call__ gets the following parameters:
|
|
24 |
fd - OS file descriptor the event occured on, or -1
|
|
25 |
mask - bitmask of EV_* flags that represents the triggered event
|
|
26 |
|
|
27 |
The default implementation of __call__ does nothing. The method's return value will be ignored, and should be
|
|
28 |
None. Any errors raised by the callback will be printed out as warning messages, and ignored.
|
|
29 |
"""
|
|
30 |
|
|
31 |
# the underlying event object
|
|
32 |
cdef lib.event *ev
|
|
33 |
|