[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: C coroutines in ANSI C
- From: Wim Couwenberg <wcou@...>
- Date: Fri, 05 Aug 2005 13:52:46 +0200
Hi David,
what a coincidence! I was just playing with this exact fiber idea on
Win32. Currently I'm just testing a first version. I was planning to
post about it later but since you brought this up I'll provide my
implementation a bit early. (It does not check thouroughly enough for
all kinds of error conditions so be careful.)
My 'fiber' library is written for Win32 and Lua 5.0.2. It copies the
coroutine semantics:
fiber.create(a_start_func)
fiber.resume(a_fiber [, args])
fiber.yield([results])
At least it builds and the first tests seem to come out OK... :-)
Fibers should be resumable across C boundaries (the implementation does
that already of course).
If a gc function yields we're into trouble though. I don't suppose that
a gc can run while another gc is still suspended without causing some
major damage...
Each fiber currently allocates a stack of default size. This could be
tweaked if necessary.
Anyway, play around with it if you like!
Wim
Attachment:
luafiber.tgz
Description: application/compressed