Project Loom: Fibers and Continuations for the Java Virtual Machine
cr.openjdk.java.net
cr.openjdk.java.net
I have some experience with it and I found it to be a very well designed and documented API. I hope to see it in the JVM someday.
The person behind it is pretty active online and does some other interesting things (the TLA+ subreddit), not sure if they are an hn reader but I hope they chime in here.
- http://www.baeldung.com/java-completablefuture Promises
- http://vertx.io/ Event Loop
- https://akka.io/ and http://www.paralleluniverse.co/quasar/ Actors
- https://projectreactor.io/ and https://github.com/ReactiveX/RxJava Reactive, event-based
- https://kotlinlang.org/docs/reference/coroutines.html Kotlin coroutines. Something like Project Loom from what I gathered from the article. Can be easily used as lightweight threads, async/await, actors, etc.
- Clojure with its own mix https://purelyfunctional.tv/guide/clojure-concurrency-the-ul...
What loom seems to offer is the best of both worlds; going back to writing simpler code (e.g. regular "blocking" io code) while scaling much better.
Every IO library would need to migrate to something non blocking. This might happen with some - currently some use Netty and NIO - but e.g. JDBC drivers are synchronous.
I am pretty sure that's not the case with Kotlin coroutines :)
The detail, nuance, and humility present in this article give me some hope that pathological misbehavior of other M:N scheduling models (see Bryan Cantrill's rant/paper about this for more info) may be avoided if something like that comes to the JVM. However, the sheer complexity of the existing JVM code, as the authors point out, may present an obstacle to that quality. Figuring out yield points for coroutines across a large java codebase seems like it would be . . . painful, to say the least.
It would be nice just to have TLS that works with NIO[2].
1. The paper discusses an implementation of lightweight threads in cooperation with the kernel, in a way that requires switching back and forth between user and kernel mode.
2. The paper was written before the advent of work-stealing schedulers (first popularized in Cilk). Work stealing schedulers have proven themselves to be very efficient for scheduling lightweight threads that block often (on IO or communication with other threads), and have been used with great success in both Erlang and Go. They address the scheduling problems discussed in the paper.
That was one of the most powerful things about Lua's coroutines. Back in games we'd use the yield value as the number of frames to skip before rescheduling giving a really nice coarse grained control over coroutine execution.
It also opens up lazy sequences and all sort of other really useful things.
produce 1
fiber sleep 100ms
suggesting that at least they're aware of its usefulness. In any case, it's pretty easy to simulate that with a bit of mutable private state.[1] https://en.wikipedia.org/wiki/Green_threads#Green_threads_in...
Well, it depends on what you're trying to do. Having the option of using either is preferable.
What is offered here is strictly better than the current or previous state.