4 ms·
In Quasar[1] -- a library that adds true fibers (just like Go's goroutines) to the JVM -- we've decided to go with copying stacks as well (this is the current,
by pron 12y ago
In Quasar[1] -- a library that adds true fibers (just like Go's goroutines) to the JVM -- we've decided to go with copying stacks as well (this is the current, and original, implementation). Of course, Java doesn't have pointers into the stack, so there's no need to fix any pointers when copying, and the implementation can be in pure Java.
[1]: https://github.com/puniverse/quasar https://github.com/puniverse/quasar
- smegel 12y agoInteresting. Is it like Python's Gevent in that it patches otherwise blocking calls (say socket.recv) to return to the Quasar runtime so it can switch fibers?
- pron 12y agoIt does use bytecode injection, but it doesn't automagically intercept calls. Quasar's users use fiber-compatible implementations of existing APIs (so the code is the same, but you have to explicitly call a fiber compatible method). Those implementations aren't built from the ground up, but thin wrappers around the original library. Usually, the library's asynchronous API is used under the covers to implement its synchronous API in a way that's fiber- rather than thread-blocking.