This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Coroutines


Dustin Laurence <dustin@laurences.net> writes:

> I'm pretty sure this is stepping into deep quicksand, but I'll ask
> anyway...I'm interested in writing an FE for a language that has
> stackable coroutines (Lua-style, where you can yield and resume
> arbitrarily far down the call stack).  I'm trying to wrap my head around
> what would be involve and how awful it would be.
> 
> There are a few "coroutines in C" packages packages laying around, but
> they don't seem to be stackable (I'm sure the ones based on Duff's
> device aren't).  Since you can't switch call stacks from C I think what
> I want is impossible at that level.

You might want to look at the SUS functions
getcontext/setcontext/makecontext/swapcontext.  They allow you to
switch call stacks in C, although maybe not quite in the way you were
hoping.  However, they're obsolescent; SUS suggests using threads
instead.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]