[Mono-devel-list] Coroutines
Rodrigo B. de Oliveira
rbo at acm.org
Wed Sep 22 07:04:57 EDT 2004
You might try something like C#/Python/Boo yield statement to simulate
true coroutines:
def update():
while true:
print("updating...")
yield null
def main():
while true:
print("main thread...")
yield null
i = 0
for ignored in zip(update(), main()):
print(".")
break if i > 10
i += 1
There are some limitations wrt exception handling, you'd have to test it
to see if you can live with them...
Unfortunately the boo compiler still cant handle the program above (it
should in a week or so) and I'm not sure about IronPython so mcs/gmcs
might be your only option right now, c#'s syntax is just a little
heavier, not a big deal.
cheers,
Rodrigo
Em Ter, 2004-09-21 às 15:32, Joe Ante escreveu:
> Hi Miguel and Rafael,
>
> > I agree with Miguel, that you don't need specific CoRoutines support,
> > just use the Thread class.
> >
> > Your code could be transformed in
> >
> > void Update ()
> > {
> > Console.WriteLine ("Starting up");
> > System.Threading.Thread.Sleep(20000); // every other thread will
> > continue to execute
> > Console.WriteLine ("20 seconds later");
> > }
> I am looking for something less heavyweight than threads.
> ...
More information about the Mono-devel-list
mailing list