[External] : Re: Single Thread Continuation

Ron Pressler ron.pressler at oracle.com
Wed Jul 5 12:09:48 UTC 2023



> On 5 Jul 2023, at 12:56, Alex Otenko <oleksandr.otenko at gmail.com> wrote:
> 
> Now, how will the generator stop? You have the close() in finalize(), and a dance around hasNext() to totally order the delivery of elements vs end of stream.

There is no generators JEP on the table at the moment so this entire discussion is up in the air, but the generator signals completion by simply terminating (recall the Continuation.isDone() method that queries whether the continuation is terminated or suspended). The consumer signals completion by simply not consuming any more elements. When the reference to the generator is dropped it can be collected (this is how it works for iterators and streams, too).

— Ron


More information about the loom-dev mailing list