Does anyone know, in the new Swift async/await
stuff, is there any difference between TaskGroup async
and spawn
, or are they pure synonyms? (If they are synonyms, I rather like spawn
better. async
looks like we're opening an async
block, and that's not what we're doing at all.)
https://developer.apple.com/documentation/swift/taskgroup/3814850-async
https://developer.apple.com/documentation/swift/taskgroup/3814884-spawn
SE-0304, tells us that spawn
was renamed async
as part of the second review:
TaskGroup.spawn
andTaskGroup.spawnUnlessCancelled
have been renamed toTaskGroup.async
andTaskGroup.asyncUnlessCancelled
which are to be their final names. This aligns the naming with the renamedasync let
as the word signifying creation of a child task.
The portion in italics has subsequently been removed and the third review has renamed it again:
- renamed
TaskGroup.async
andTaskGroup.asyncUnlessCancelled
toTaskGroup.addTask
andTaskGroup.addTaskUnlessCancelled
. The fundamental behavior here is that we're adding a task to the group. add by itself does not suffice, because we aren't adding a value (accessible vianext()
), we are adding a task whose value will be accessible vianext()
. It also parallels the use ofTask { ... }
to create top-level tasks.