Skip to content

Latest commit

 

History

History
64 lines (38 loc) · 1.23 KB

Task.rst

File metadata and controls

64 lines (38 loc) · 1.23 KB
.. py:module:: dvbcss.task

Task scheduling for clocks

Module: dvbcss.task

.. automodule:: dvbcss.task
   :noindex:

See :doc:`task-internals` for information on how the internals of the Task module work.

A simple example:

from dvbcss.clock import SysClock
from dvbcss.clock import CorrelatedClock
from dvbcss.task import sleepFor, runAt

s = SysClock()
c = CorrelatedClock(parentClock=s, tickRate=1000)

# wait 1 second
sleepFor(c, numTicks=1000)

# schedule callback in 5 seconds
def foo(message):
    print "Callback!", message

runAt(clock=c, whenTicks=c.ticks+5000, foo, "Tick count progressed by 5 seconds")

# ... but change the correlation to make the clock jump 1 second forward
#     causing the callback to happen one second earlier
c.correlation = (c.correlation[0], c.correlation[1] + 1000)

# ... the callback will now happen in 4 seconds time instead
.. autofunction:: dvbcss.task.sleepUntil

.. autofunction:: dvbcss.task.sleepFor

.. autofunction:: dvbcss.task.scheduleEvent

.. autofunction:: dvbcss.task.runAt