Contents

TaskGroup.Iterator

A type that provides an iteration interface over the results of tasks added to the group.

Declaration

struct Iterator

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. 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. For example:

group.addTask { 1 }
for await r in group { print(r) }

// Add a new child task and iterate again.
group.addTask { 2 }
for await r in group { print(r) }

Topics

Instance Methods

Type Aliases

Default Implementations

See Also

Supporting Types