Single Thread Continuation
Alex Otenko
oleksandr.otenko at gmail.com
Mon Jul 3 10:29:11 UTC 2023
Well, convenient or not, closing is necessary. How else can a generator
tell the consumer that no more values are forthcoming?
Ditto for closing the channel by the consumer. Barring advanced cases with
sharing the generator, you can have try-with-resources take care of closing
things for you.
On Mon, 3 Jul 2023, 11:18 Attila Kelemen, <attila.kelemen85 at gmail.com>
wrote:
> Alex Otenko <oleksandr.otenko at gmail.com> ezt írta (időpont: 2023. júl.
> 3., H, 11:41):
>
>> It should really be channels, not queues. So that either end can close
>> it. That can also solve the problem that you raise about generators being
>> stuck in the scheduler forever.
>>
>>>
>>>
> That is only enough if you can "close" the iterator (which is of course
> also a common use case), but in many cases you just want a normal
> `Iterator` which doesn't need to be closed. In that case, it would be rude
> to force the client code to close the iterator out of convenience of the
> implementation (since in that case you wouldn't need it, if you implemented
> it normally).
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/loom-dev/attachments/20230703/c3b9dd10/attachment.htm>
More information about the loom-dev
mailing list