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

Task scheduling for clocks

Module: dvbcss.task

Introduction

dvbcss.task

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

Example

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

Functions

dvbcss.task.sleepUntil

dvbcss.task.sleepFor

dvbcss.task.scheduleEvent

dvbcss.task.runAt