c/c++ coroutines with setcontext
James Mansion
james at mansionfamily.plus.com
Mon May 25 10:59:23 CEST 2009
Marc Lehmann wrote:
> On Fri, May 22, 2009 at 07:38:15PM +0100, James Mansion <james at mansionfamily.plus.com> wrote:
>
>>> broken implementations, it has never been successfully standardised etc.).
>>>
>>>
>> Are you sure that the situation is that dismal?
>>
>> Try also http://www.dekorte.com/projects/opensource/libcoroutine/
>>
>
> absolutely. unlike that guy, i don't compile my software on gnu/linux only
> and call it portable :) it would be nice if ucontext functions did work
> (ok, they are extremely slow (syscall), but at least they would be hassle-free).
>
Have you actually checked what the portability is of Steve Dekorte's code?
You comment seems out of sync with this section at the head of Coro.c:
Credits
Originally based on Edgar Toernig's Minimalistic cooperative
multitasking
http://www.goron.de/~froese/
reorg by Steve Dekorte and Chis Double
Symbian and Cygwin support by Chis Double
Linux/PCC, Linux/Opteron, Irix and FreeBSD/Alpha, ucontext
support by Austin Kurahone
FreeBSD/Intel support by Faried Nawaz
Mingw support by Pit Capitain
Visual C support by Daniel Vollmer
Solaris support by Manpreet Singh
Fibers support by Jonas Eschenburg
Ucontext arg support by Olivier Ansaldi
I wouldn't like to infer that this stuff doesn't work just because a
different
coroutine system has some issues.
You can probably infer something about the portability of Steve's code from
the presence of an io port on the platform.
> in fact, the only way to implement coroutines on freebsd and netbsd that I
> found is using the native thread library (which on netbsd is only slightly
> slower as the ucontetx functions, fortunately, as it's userspace).
>
Note that this is out of date for NetBSD 5 and for default modern builds
on FreeBSD.
James
More information about the libev
mailing list