Using continuations to do your own scheduling...
jkraska at bbn.com
Thu May 4 02:43:44 CEST 2000
Christian, et al.,
Thought you might appreciate this. It's a fairly simple
example of how to do your own scheduling with continuations
in Python. In a more advanced M&S setting, the call to
time.sleep(s.ticks) would instead be something which
coordinated the passage of model time, not actual wall-
Note the presumptions of call depth and the scheduler;
this obviously has to be thought out carefully and could
get you into major trouble if you're wrong. The trick
is to make certain that no one but you is calling your
s.c = c1
s.ticks = ticks
t = type(s)
if t.__name__ == "instance": #WRONG: what's the syntax f/ "Schedulable"?
elif s == 1:
print " procedure succeeded explicitly"
elif s == 0:
print " procedure failed explicitly"
print " WARNING UNINTERPRETABLE VALUE: IMPLICIT SUCCESS"
More information about the Python-list