Continuations in Java

前端 未结 11 1968
再見小時候
再見小時候 2020-12-05 00:20

Is there a good implementation of continuations in Java?

If so, what is the overhead like? The JVM wasn\'t designed with these sort of things in mind, right? So is t

相关标签:
11条回答
  • 2020-12-05 00:46

    If you don't mind implicit continuations, Kilim is a great option. It works by processing annotated methods and generating the continuations in bytecode for you. Obviously it does a lot more since it's a framework, but if you want the (excellent) performance of thread-safe continuations, it's worth a look.

    0 讨论(0)
  • 2020-12-05 00:48

    Another library by Matthias Mann:

    http://www.matthiasmann.de/content/view/24/26/

    http://www.matthiasmann.de/java/Continuations/

    0 讨论(0)
  • 2020-12-05 00:50

    Scala also runs on JVM. So it might be relevant.

    What are Scala continuations and why use them?

    In addition Scala has somewhat similar async/await feature:

    http://docs.scala-lang.org/sips/pending/async.html

    0 讨论(0)
  • 2020-12-05 00:52

    Play! framework version 1.2.x also has support for continuations integrated with async http goodies.

    Note that Play 1.2.x continuations only work with the inbuilt Netty server.

    And Play 2.x still has no support for continuations.

    0 讨论(0)
  • 2020-12-05 00:54

    Consider also Kotlin Coroutines.

    It's implemented via potentially more performant CPS transformations (still stackful) and can use any async executor under the hood like ForkJoinPool or Quasar integration.

    Comes with handy guided library.

    Beware of some tooling and reflection pitfalls.

    0 讨论(0)
  • 2020-12-05 01:01

    Jetty has continuation support. There is further discussion and some samples at DZone.

    I can't advise on the efficiencies or otherwise, other than to say that the Mortbay team always appear concious of such issues. There will most likely be a discussion of implementation trade-offs somewhere on the Jetty site.

    0 讨论(0)
提交回复
热议问题