How to terminate a continuation early and call `finally` blocks?

Ron Pressler ron.pressler at oracle.com
Tue Sep 8 12:39:16 UTC 2020


Loom’s continuation are a capability that’s used internally by the 
JDK to implement virtual threads.

Whether or not the JDK will one day also use that mechanism to implement
other constructs, like generators, is beyond our scope at this time.

— Ron



On 8 September 2020 at 13:35:04, Михаил Кузьмин (m.kuzmin at darkleaf.ru(mailto:m.kuzmin at darkleaf.ru)) wrote:

> JS generators have the `return` method:
>  
> ```javascript
> var fn_gen = function* () {
> try {
> yield
> }
> finally {
> console.log("finally")
> }
> };
>  
> var gen = fn_gen();
> gen.next()
> // => {value: undefined, done: false}
> gen.return()
> // => finally <= the finally block has been executed
> // => {value: undefined, done: true}
> ```
>  
> Will it be possible with Loom's continuations?
>  



More information about the loom-dev mailing list