On Fri, 9 Sep 2005, felix winkelmann wrote: > On 9/9/05, Daniel B. Faken <[EMAIL PROTECTED]> wrote: > > From http://luajit.luaforge.net/coco.html: > > "Coco is a small extension to get True C Coroutine semantics for Lua 5.1. > > > > Yes this is clever. I thought about using makecontext/setcontext > (patching setjmp > isn't that nice, really) myself a while ago. Another nice property of this > would be that C frames have dynamic extent (they could be garbage > collected).
Actually I just noticed that, according to the manual, Chicken already kind of supports the "Coroutines in C" idea: "When multiple threads are running concurrently, and control switches from one thread to another, then the continuation of the current thread is captured and saved. Any pending C stack frame still active from a callback will remain on the stack until the threads is re-activated again." [and, since CHICKEN_yield() is just a callback to (thread-yield!), this should work from C] -- right? I have NOT tried this yet! I guess in this sense Chicken has something like Lua's "One-shot continuations", for C. [though I should include the qualifications in the manual: the continuation (ha) of the above quote is: "This means that in a multithreading situation, when C callbacks are involved, the available nursery space can be smaller than expected. So doing many nested Scheme->C->Scheme calls can reduce the available memory up to the point of thrashing. It is advisable to have only a single thread with pending C stack-frames at any given time."] - Daniel _______________________________________________ Chicken-users mailing list [email protected] http://lists.nongnu.org/mailman/listinfo/chicken-users
