I’m not sure what mtimmerm had in mind, but I think it depends what API they give us. I’m not sure they know yet what all the API will be. If the Continuation
is public, then it’s possible. Also, part 2 of State of Loom had an example with “channels”. I think that could do it. Kotlin-ish pseudocode…
val channel = Channel()
Thread.startVirtualThread {
var n = 0
while (true) {
channel.send(n)
n += 1
}
}
val iter = Iterator {
fun next(): String { channel.receive() }
}
for (n in iter) { ... }