[External] : Re: Single Thread Continuation

Robert Engels rengels at ix.netcom.com
Tue Jul 11 13:49:21 UTC 2023


You don’t need a closable iterator. It is trivial to modify the code I provided to make the outer generator instance AutoClosable to be used with TwR and if the iterator is used after the outer is closed it fails with an IllegalStateException (or NoSuchElementException with ‘generator closed’ as the cause. 

> On Jul 11, 2023, at 8:39 AM, Andrew Haley <aph-open at littlepinkcloud.com> wrote:
> 
> On 7/5/23 13:09, Ron Pressler wrote:
>> When the reference to the generator is dropped it can be collected (this is how it works for iterators and streams, too).
> 
> Yes, but while it can be it may not be, and this is a real problem if the
> generator holds a scarce resource. We really do need to be able to close the
> consuming side of a generator in such a way that we interrupt the generating
> thread, allowing it time to release resources. Do we need something like a
> closeable Iterator?
> 
> -- 
> Andrew Haley  (he/him)
> Java Platform Lead Engineer
> Red Hat UK Ltd. <https://www.redhat.com>
> https://keybase.io/andrewhaley
> EAC8 43EB D3EF DB98 CC77 2FAD A5CD 6035 332F A671
> 


More information about the loom-dev mailing list