A brief description can be found at http://msofer.com:8080/wiki?name=Coroutines,
otherwise the code in tests/unsupported.test is the only documentation.
Test! Enjoy! Help make it better
Cheers
Miguel
thanks for you work
Thanks Miguel ! Stackless Tcl : a dream come true for so many of us...
As a first trivial application: "long computation keeping the event-
loop responsive":
proc f {} {
for {SOME} {LONG} {LOOP} {
COMPUTE A FEW THINGS
after idle ff
yield
}
set ::result ...
}
coroutine ff f
vwait ::result
Of course [after idle] can be replaced by [after $some_finite_delay],
allowing to throttle the amount of CPU left idle.
-Alex
Colin McCormack has been experimenting with coroutines for his 'wub' webserver.
Quoting him from the chat:
colin lemme show you the source file which implements Co, and that which
implements Rest (doing nearly the same thing, but without coro) ... I think the
difference speaks volumes.
colin http://code.google.com/p/wub/source/browse/trunk/Domains/Co.tcl
colin http://code.google.com/p/wub/source/browse/trunk/Domains/Rest.tcl
colin The complexity of the latter is not entirely due to the model, but is
largely due to it - I had to provide all the context-saving and parsing stuff.
colin I think you'll agree Co (soon to be Coco, dammit) is much cleaner and simpler.
colin I'll have to implement some idle-timeout stuff, which'll add a few dozen
LOC, but it's clean
> yahalom wrote:
>> It was good if there was an example of something done both in todays
>> tcl commands and then with the new commands. This might make the new
>> commands and coroutines clearer. They are so different from what we
>> are used to, it makes them hard to grasp. If the example was also with
>> a verbal explanation of the problem that that solution tries to solve,
>> it would be even better.
>>
>> thanks for you work
>
> Colin McCormack has been experimenting with coroutines for his 'wub'
> webserver. Quoting him from the chat:
>
> colin lemme show you the source file which implements Co, and that which
> implements Rest (doing nearly the same thing, but without coro) ... I
> think the difference speaks volumes.
> colin http://code.google.com/p/wub/source/browse/trunk/Domains/Co.tcl
> colin http://code.google.com/p/wub/source/browse/trunk/Domains/Rest.tcl
the links seem not to work ;-)
Arnulf
Aarghh ... colin mentined he wanted to rename it! They are now
http://code.google.com/p/wub/source/browse/trunk/Domains/Coco.tcl
http://code.google.com/p/wub/source/browse/trunk/Domains/Rest.tcl