qmsk/net/lib/event2/event.pxd
changeset 57 8c4032265c8c
parent 52 722fc70a197a
equal deleted inserted replaced
56:07ed878c847b 57:8c4032265c8c
     1 """
     1 """
     2     Core `struct event` type.
     2     Core `struct event` type.
     3 """
     3 """
     4 
     4 
     5 cimport qmsk.net.lib.event2.lib as lib
     5 cimport qmsk.net.lib.event2.lib as lib
       
     6 
       
     7 from qmsk.net.lib.event2.base cimport event_base
     6 
     8 
     7 # internal helper method for handling timeout arguments
     9 # internal helper method for handling timeout arguments
     8 cdef lib.timeval* build_timeout (lib.timeval *tv, object timeout = ?) except? <lib.timeval *>-1
    10 cdef lib.timeval* build_timeout (lib.timeval *tv, object timeout = ?) except? <lib.timeval *>-1
     9 
    11 
    10 cdef class event :
    12 cdef class event :
    24 
    26 
    25         The lifetime of event objects is slightly non-trivial, in that they will actually hold a reference to
    27         The lifetime of event objects is slightly non-trivial, in that they will actually hold a reference to
    26         themselves while "active". In other words, .add() will aquire an internal reference, which will be released
    28         themselves while "active". In other words, .add() will aquire an internal reference, which will be released
    27         before the __call__().
    29         before the __call__().
    28 
    30 
    29         XXX: it might be better for refcounting if the event_base were to keep a reference to each event
       
    30         XXX: or if we kept a reference to the event_base? Might be even better
       
    31 
       
    32         XXX: propagate errors (including e.g. KeyboardInterrupt?) from __call__ to event_base.loop()?
    31         XXX: propagate errors (including e.g. KeyboardInterrupt?) from __call__ to event_base.loop()?
    33     """
    32     """
       
    33 
       
    34     # reference to our supporting event_base to ensure we don't lose it
       
    35     cdef readonly event_base base
    34 
    36 
    35     # the underlying event object
    37     # the underlying event object
    36     cdef lib.event *ev
    38     cdef lib.event *ev
    37 
    39 
    38     # slightly different meaning from libevent's "active", this is used to track our own refcount
    40     # slightly different meaning from libevent's "active", this is used to track our own refcount