yield return based on Coroutines

Andrew Haley aph-open at littlepinkcloud.com
Tue Oct 3 10:33:19 UTC 2023


On 8/28/23 10:12, Alan Bateman wrote:
 > This looks fun! It's probably best to bring this to loom-dev. In its archives you'll find several discussions about generators as several people have been interested in that topic. Even when thread confined, the main concern has been that exotic control flow yields leads to surprising behavior with many of the existing constructs, e.g. in your example think about behavior with finally blocks, try-with-resources, locks, ... when the iterator is not fully consumed.

Hmm, yes, I was thinking of doing something very much like this myself,
so I'm glad I saw your reply.

Even while the iterator is still running, there are still some potential
surprises. I wonder if, whatever we do, any form of coroutine will need to
have its own identity as an instance of Thread.

-- 
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