qmsk/net/lib/event2/event.pxd
author Tero Marttila <terom@fixme.fi>
Fri, 28 Aug 2009 21:58:47 +0300
changeset 39 075eaafa80a7
child 41 02f7c0539843
permissions -rw-r--r--
initial lib.event2 code
"""
    Core `struct event` type.
"""

cimport qmsk.net.lib.event2.lib as lib

# internal helper method for handling timeout arguments
cdef lib.timeval* build_timeout (lib.timeval *tv, object timeout = ?) except? <lib.timeval *>-1

cdef class event :
    """
        Create a new event object with the given parameters.
        
        An event tracks a single OS file descriptor with some set of events (EV_READ/EV_WRITE) and an optional timeout.
        
        An event is associated with some event_base, which handles the event mechanism.
        
        Arguments:
            base        - event_base to use for this event
            fd          - OS file descriptor to watch, or -1
            events      - bitmask of EV_* flags that represents the events to wait for

        When the event fires, it will "call" this event object, so __call__ gets the following parameters:
            fd          - OS file descriptor the event occured on, or -1
            mask        - bitmask of EV_* flags that represents the triggered event
    
        The default implementation of __call__ does nothing. The method's return value will be ignored, and should be
        None. Any errors raised by the callback will be printed out as warning messages, and ignored.
    """

    # the underlying event object
    cdef lib.event *ev