Hacker News new | past | comments | ask | show | jobs | submit login

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.



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.


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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: