On Sat, Jun 11, 2011 at 1:27 PM, Bastien ROUCARIES <roucaries.bast...@gmail.com> wrote: > Le jeudi 9 juin 2011 19:41:06, Aneesh Kumar K.V a écrit : >> On platforms that doesn't support makecontext use gthread >> based coroutine implementation. > > Why not using one of the existing lib of coroutine or improving it ? > > Could you give some hints ? > > Why not use http://cvs.schmorp.de/libcoro/coro.h what is the base of the perl > coroutine lib and thus well tested on a lot of > plateform?
libcoro provides a different API where you need to know which coroutine called you in order to yield back to it later. Since the common use-case is to transfer control to a coroutine and then have it yield back, this caller information is very handy and avoids littering code with explicit caller variables. We have ucontext, Win32 Fibers, and now GThread implementations of coroutines. I think it's not worth switching to libcoro because it is just a little different with its own quirks and limitations, not clearly better. This code actually started out from the gtk-vnc coroutines implementation, so we did start by reusing code... :) Stefan