1 / 12

Continuations And Java

Continuations And Java. Regis - xu.regis@gmail.com. Agenda. What is Continuations Why Continuations Implementations in Java Jetty Continuations API JavaFlow Kilim JVM Continuations. What is Continuations. Definition from wikipedia:

kiana
Télécharger la présentation

Continuations And Java

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Continuations And Java Regis - xu.regis@gmail.com

  2. Agenda • What is Continuations • Why Continuations • Implementations in Java • Jetty Continuations API • JavaFlow • Kilim • JVM Continuations

  3. What is Continuations • Definition from wikipedia: • Give a programming language the ability to save the execution state at any point and return to that point at alter point in the program • Basic characteristics: • Local data (variables, ...) is restored on successive calls. • Execution of a coroutine is only suspended when it yields, to be resumed when the coroutine is called again.

  4. started! 0 returned a continuation 1 returned another continuation

  5. Why Continuations • Thread is heavy and expensive • Writing asynchronous code in the synchronous style • Supporting functional languages • SAX parser • Web servers • linearize complex interactions • “back button” problem

  6. Implemented As Library • Jetty 6.0 • For resolving AJAX polling problem • Event based + retry

  7. Implemented As Library (Cont.) • Instrumentation byte code • Save current stack frames • Store local variables • Save PC • Restore stack trace • goto + switch table

  8. From A Thread of One’s Own

  9. Implemented As Library (Cont.) • Implementations • JavaFlow • Asymmetric coroutines: each yield needs to specify which coroutine should come next. • Kilim • Symmetric coroutines: a scheduler decides which coroutine should run next after a yield. • Framework has a thread pool and decide which coroutine run on which thread. • RIFE/Continuations (WebWork)

  10. Implemented In JVM • Support save and restore stack frames by JVM • No instrumentation needed • APIs is similar with library provided

  11. References • http://wiki.jvmlangsummit.com/JVM_Continuations • http://classparser.blogspot.com/2010/01/coroutines.html • http://lambda-the-ultimate.org/node/1002 • http://sourceforge.net/projects/jauvm/ • http://commons.apache.org/sandbox/javaflow/ • http://rifers.org/wiki/display/RIFECNT/Home • http://www.artima.com/lejava/articles/continuations.html • A Thread of One’s Own • Lazy Continuations for Java Virtual Machines

  12. Question?

More Related