Search |
|||
Rémi Forax's blogHoly crap: JVM has coroutine/continuation/fiber etc.Posted by forax on November 19, 2009 at 4:01 PM PST
Lukas Stadler is my hero,
at last JVM summit,
he just explain how coroutine and friends can be
implemented in the VM
and guess what, it now works (currently only with C1).
Generator
I have always wanted to have generator
in Java. After all, Python have this feature, Ruby and C#(*) too.
The implementation is based on continuation, yield stops the current execution and saves the stack frames as an object,
the value passed as argument to yield is received by the method next of the iterator. When next next is called,
the continuation is resumed, so the execution is restarted just after the yield.
(*) There is some weird limitations in C# but a friend of mine says to me that C# 4 doesn't have them anymore. By example, this generator specifies an iterator that will return the Fibonacci's numbers: public class FibonacciGenerator extends AbstractGenerator If you want to test it, there is two solutions:
$ /usr/jdk/jdk1.7.0b75/bin/java -coroutine -Xbootclasspath/p:coroutine.jar -cp classes FibonacciGeneratorTest value 1 value 2 value 3 value 5 value 8 The code of the abstract generator is here: public abstract class AbstractGenerator
Cheers, »
Related Topics >>
Open JDK Virtual Machine Comments
Comments are listed in date ascending order (oldest first)
Excellent news...
Submitted by opinali on Fri, 2009-11-20 06:08.
...not only for additional Java features, but for extra other-languages support (e.g. Scheme) and for interesting use cases like continuation-based web frameworks.
I hope the delay in JDK 7 will have the side effect that a bigger number of interesting MLVM projects will have time to mature - I'm strongly interested in full tail call support - to be part of the JDK 7 FCS.
Re: Excellent news...
Submitted by forax on Fri, 2009-11-20 07:02.
I wonder if a yield as a tail call can be optimized :) Rémi Holy crap indeed!
Submitted by markmahieu on Fri, 2009-11-20 03:19.
This is very cool. Thanks for sharing!
|
CategoriesArchivesNovember 2009
October 2009 September 2009 August 2009 July 2009 June 2009 May 2009 April 2009 February 2009 January 2009 December 2008 November 2008 October 2008 September 2008 July 2008 May 2008 April 2008 March 2008 February 2008 January 2008 November 2007 October 2007 September 2007 August 2007 July 2007 June 2007 May 2007 March 2007 February 2007 January 2007 December 2006 November 2006 October 2006 September 2006 August 2006 July 2006 Recent Entries |
||
|
|
GOTO on steroids