News for hackers. Stuff that matters.
Re:Fixing the callback spaghetti in node.js by koush on Thursday September 29, 2011 @12:27AM (#3051123)
That's exactly how this was done. I'm going to implement "yield" as well when I have some time. They both just leverage coroutines.
Re:Fixing the callback spaghetti in node.js by tilgovi on Thursday September 29, 2011 @12:55AM (#3051180)
node-fibers is one attempt to put coroutines into node. I like it because it uses libcoro, which is nice and tight and uses ucontext, and because it works as a module without forking the core of node. Once you've 'fiberized' the server modules to start each request in its own fiber and implemented a call-with-current-continuation on Function.prototype, we're pretty much at the same place you've arrived but without new keywords.
Re:Fixing the callback spaghetti in node.js by kqueue on Thursday September 29, 2011 @01:23AM (#3051230)
Ah I missed this. I once tried to implement coroutines in v8 but v8 makes use of getspecific and setspecific pthread methods which makes it more complicated.