RPKI Engine  1.0
Public Member Functions | Public Attributes | Static Public Attributes
rpki::async::timer Class Reference
Inheritance diagram for rpki::async::timer:
Inheritance graph
Collaboration diagram for rpki::async::timer:
Collaboration graph

List of all members.

Public Member Functions

def __cmp__
def __del__
def __init__
def __repr__
def cancel
def clear
def errback
def handler
def is_set
def runq
def seconds_until_wakeup
def set
def set_errback
def set_handler
def trace

Public Attributes

 errback
 handler
 when

Static Public Attributes

 gc_debug = False
 Verbose chatter about timers states and garbage collection.
list queue = []
 Timer queue, shared by all timer instances (there can be only one queue).
 run_debug = False
 Verbose chatter about timers being run.

Detailed Description

Timer construct for event-driven code.  It can be used in either of two ways:

- As a virtual class, in which case the subclass should provide a
  handler() method to receive the wakup event when the timer expires; or

- By setting an explicit handler callback, either via the
  constructor or the set_handler() method.

Subclassing is probably more Pythonic, but setting an explict
handler turns out to be very convenient when combined with bound
methods to other objects.

Definition at line 82 of file async.py.


Constructor & Destructor Documentation

def rpki::async::timer::__init__ (   self,
  handler = None,
  errback = None 
)

Definition at line 109 of file async.py.

def rpki::async::timer::__del__ (   self)

Definition at line 146 of file async.py.


Member Function Documentation

def rpki::async::timer::__cmp__ (   self,
  other 
)

Definition at line 142 of file async.py.

def rpki::async::timer::__repr__ (   self)

Definition at line 214 of file async.py.

References handler, and when.

def rpki::async::timer::cancel (   self)
Cancel a timer, if it was set.

Definition at line 149 of file async.py.

References gc_debug, and trace().

Referenced by clear().

Here is the call graph for this function:

Here is the caller graph for this function:

def rpki::async::timer::clear (   cls)
Cancel every timer on the queue.  We could just throw away the
queue content, but this way we can notify subclasses that provide
their own cancel() method.

Definition at line 239 of file async.py.

References cancel().

Referenced by rpki::x509::DER_object::__init__(), and rpki::x509::DER_object::check_auto_update().

Here is the call graph for this function:

Here is the caller graph for this function:

def rpki::async::timer::errback (   self,
  e 
)
Error callback.  May be overridden, or set with set_errback().

Definition at line 184 of file async.py.

References errback.

Handle a timer that has expired.  This must either be overriden by
a subclass or set dynamically by set_handler().

Definition at line 167 of file async.py.

References handler.

def rpki::async::timer::is_set (   self)
Test whether this timer is currently set.

Definition at line 161 of file async.py.

References queue.

def rpki::async::timer::runq (   cls)
Run the timer queue: for each timer whose call time has passed,
pull the timer off the queue and call its handler() method.

Definition at line 198 of file async.py.

def rpki::async::timer::seconds_until_wakeup (   cls)
Calculate delay until next timer expires, or None if no timers are
set and we should wait indefinitely.  Rounds up to avoid spinning
in select() or poll().  We could calculate fractional seconds in
the right units instead, but select() and poll() don't even take
the same units (argh!), and we're not doing anything that
hair-triggered, so rounding up is simplest.

Definition at line 218 of file async.py.

def rpki::async::timer::set (   self,
  when 
)
Set a timer.  Argument can be a datetime, to specify an absolute
time, or a timedelta, to specify an offset time.

Definition at line 126 of file async.py.

References gc_debug, queue, trace(), and when.

Referenced by rpki::x509::DER_object::__init__().

Here is the call graph for this function:

Here is the caller graph for this function:

def rpki::async::timer::set_errback (   self,
  errback 
)
Set a timer's errback.  Like set_handler(), for errbacks.

Definition at line 191 of file async.py.

def rpki::async::timer::set_handler (   self,
  handler 
)
Set timer's expiration handler.  This is an alternative to
subclassing the timer class, and may be easier to use when
integrating timers into other classes (eg, the handler can be a
bound method to an object in a class representing a network
connection).

Definition at line 174 of file async.py.

def rpki::async::timer::trace (   self,
  msg 
)
Debug logging.

Definition at line 118 of file async.py.

References gc_debug.

Referenced by cancel(), and set().

Here is the caller graph for this function:


Member Data Documentation

Definition at line 193 of file async.py.

Referenced by errback().

rpki::async::timer::gc_debug = False [static]

Verbose chatter about timers states and garbage collection.

Definition at line 99 of file async.py.

Referenced by cancel(), set(), and trace().

Definition at line 180 of file async.py.

Referenced by __repr__(), and handler().

Timer queue, shared by all timer instances (there can be only one queue).

Definition at line 107 of file async.py.

Referenced by rpki::http::http_client::handle_connect(), is_set(), rpki::http::http_queue::return_result(), rpki::http::http_queue::send_request(), and set().

Verbose chatter about timers being run.

Definition at line 103 of file async.py.

Definition at line 109 of file async.py.

Referenced by __repr__(), and set().


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Properties