group
as AsyncSequence
doesn't feel exactly useful. There's a recent pitch about end-of-iteration behaviour of AsyncSequence
. If we ended up adopting this, this means we can do for ... in group
only once at the end. If we want to iterate through the group multiple times, we need to fallback to group.nextResult
.
What if we use See below.group.currentResults()
for AsyncSequence
instead?
On a more holistic look on spawn
vs add
, looking at the PR:
- I think it's a shame that we remove back-pressure, it could be useful when scheduling a lot of subtasks. Though it's not necessary since we can achieve it manually:
for ... in 0..<10 { group.spawn(...) } for result in group { // handle `result` group.spawn(...) }
group.spawn
andgroup.nextResult
feels like they're at odd with each other.Task.Spawned
exactly identifies one particular handler for one specific spawn, whilenextResult
anonymizes the origin. If, for example, I can't cancel one particularSpawn
because it's already completed, I have no idea which one in thegroup.nextResult
is the corresponding result.