Overview 概要
The elements returned by this iterator appear in the order that the tasks completed, not in the order that those tasks were added to the task group. このイテレータによって返される要素それらは、タスクそれらが完了した順番に現れます、それらタスクがタスクグループに加えられた順番にではなく。
This iterator terminates after all tasks have completed successfully, or after any task completes by throwing an error. このイテレータは、全てのタスクが成功裏に完了した後に終了します、または何らかのタスクがエラーをスローすることによって完了した後に。 If a task completes by throwing an error, it doesn’t return any further task results. After iterating over the results of each task, it’s valid to make a new iterator for the task group, which you can use to iterate over the results of new tasks you add to the group. You can also make a new iterator to resume iteration after a child task thows an error. For example: 例えば:
group.addTask { 1 }
group.addTask { throw SomeError }
group.addTask { 2 }
do {
// Assuming the child tasks complete in order, this prints "1"
// and then throws an error.
for try await r in group { print(r) }
} catch {
// Resolve the error.
}
// Assuming the child tasks complete in order, this prints "2".
for try await r in group { print(r) }