4 ms·
There is a great approach in Quasar [1] where you program simple blocking code, and the runtime (bytecode manipulation with a Java agent) unmounts and remounts
by BenoitP 8y ago
There is a great approach in Quasar [1] where you program simple blocking code, and the runtime (bytecode manipulation with a Java agent) unmounts and remounts thin contexts in the fat thread you are in. A light thread, if you will. No events/promises/callbacks. It does require unmounting-aware APIs, though; making you incur the usual fat thread mounting/unmounting cost if they are not available.
The author of this project is currently implementing the base element of this approach (continuations) in the JVM [2]; probably along the required rewrite of the Java standard library. I'm very excited about this!
You could start writing code in Quasar, IIRC they said it will use these continuations when they are made available. I would not be surprised if it is one of the first frameworks to make use of it.
[1] http://docs.paralleluniverse.co/quasar/ http://docs.paralleluniverse.co/quasar/
[2] http://cr.openjdk.java.net/~rpressler/loom/Loom-Proposal.html http://cr.openjdk.java.net/~rpressler/loom/Loom-Proposal.htm...
- ofrzeta 8y agoLatest news on the website from 2016. Latest commit on Github from January; build broken. Wouldn't be my first choice for starting a new project, I guess.
- bpicolo 8y ago> unmounting-aware APIs Does that mean libraries need to be rewritten to support it? In my experience, important IO-driven libraries like database access/ORMs tend to be extremely poorly supported for non-language-native concurrency strategies, or even concurrency strategies added late in a language's lifecycle.
- BenoitP 8y ago> Does that mean libraries need to be rewritten to support it? Yup. Here are the list of supported libraries [1]. > even concurrency strategies added late in a language's lifecycle Quasar code uses a regular Java Exception as a trick to stop execution and unmount, to sort of piggyback on the language features. Fibers do also implement the Thread interface; I think what you pointed at was indeed a concern of the author. I don't know how the Loom initiative look like. If you want to see how a library is adapted, here is JDBC [2]. [1] http://docs.paralleluniverse.co/comsat/#getting-started http://docs.paralleluniverse.co/comsat/#getting-started [2] https://github.com/puniverse/comsat/tree/master/comsat-jdbc/src/main/java/co/paralleluniverse/fibers/jdbc https://github.com/puniverse/comsat/tree/master/comsat-jdbc/...