@@ -16,10 +16,10 @@ import Swift
16
16
// ==== TaskGroup --------------------------------------------------------------
17
17
18
18
/// Starts a new task group which provides a scope in which a dynamic number of
19
- /// tasks may be spawned .
19
+ /// tasks may be created .
20
20
///
21
21
/// When the group returns,
22
- /// it implicitly waits for all spawned tasks to complete.
22
+ /// it implicitly waits for all child tasks to complete.
23
23
/// The tasks are canceled only if `cancelAll()` was invoked before returning,
24
24
/// if the group's task was canceled.
25
25
///
@@ -50,14 +50,14 @@ import Swift
50
50
/// Canceling the task in which the group is running
51
51
/// also cancels the group and all of its child tasks.
52
52
///
53
- /// If you call `spawn (priority:operation:)` to create a new task in a canceled group,
53
+ /// If you call `async (priority:operation:)` to create a new task in a canceled group,
54
54
/// that task is immediately canceled after creation.
55
- /// Alternatively, you can call `spawnUnlessCancelled (priority:operation:)`,
56
- /// which doesn't spawn the task if the group has already been canceled
55
+ /// Alternatively, you can call `asyncUnlessCancelled (priority:operation:)`,
56
+ /// which doesn't create the task if the group has already been canceled
57
57
/// Choosing between these two functions
58
58
/// lets you control how to react to cancellation within a group:
59
59
/// some child tasks need to run regardless of cancellation
60
- /// and others are better not even being spawned
60
+ /// and others are better not even being created
61
61
/// knowing they can't produce useful results.
62
62
///
63
63
/// Because the tasks you add to a group with this method are nonthrowing,
@@ -91,10 +91,10 @@ public func withTaskGroup<ChildTaskResult, GroupResult>(
91
91
#endif
92
92
}
93
93
94
- /// Starts a new scope in which a dynamic number of throwing tasks can be spawned .
94
+ /// Starts a new scope in which a dynamic number of throwing tasks can be created .
95
95
///
96
96
/// When the group returns,
97
- /// it implicitly waits for all spawned tasks to complete.
97
+ /// it implicitly waits for all child tasks to complete.
98
98
/// The tasks are canceled only if `cancelAll()` was invoked before returning,
99
99
/// if the group's task was canceled,
100
100
/// or if the group's body throws an error.
@@ -126,14 +126,14 @@ public func withTaskGroup<ChildTaskResult, GroupResult>(
126
126
/// Canceling the task in which the group is running
127
127
/// also cancels the group and all of its child tasks.
128
128
///
129
- /// If you call `spawn (priority:operation:)` to create a new task in a canceled group,
129
+ /// If you call `async (priority:operation:)` to create a new task in a canceled group,
130
130
/// that task is is immediately canceled after being created.
131
- /// Alternatively, you can call `spawnUnlessCancelled (priority:operation:)`,
132
- /// which doesn't spawn the task if the group has already been canceled
131
+ /// Alternatively, you can call `asyncUnlessCancelled (priority:operation:)`,
132
+ /// which doesn't create the task if the group has already been canceled
133
133
/// Choosing between these two functions
134
134
/// lets you control how to react to cancellation within a group:
135
135
/// some child tasks need to run regardless of cancellation
136
- /// and others are better not even being spawned
136
+ /// and others are better not even being created
137
137
/// knowing they can't produce useful results.
138
138
///
139
139
/// Throwing an error in one of the tasks of a task group
@@ -145,14 +145,14 @@ public func withTaskGroup<ChildTaskResult, GroupResult>(
145
145
/// nothing is canceled and the group doesn't throw an error:
146
146
///
147
147
/// withThrowingTaskGroup { group in
148
- /// group.spawn { throw SomeError() }
148
+ /// group.async { throw SomeError() }
149
149
/// }
150
150
///
151
151
/// In contrast, this example throws `SomeError`
152
152
/// and cancels all of the tasks in the group:
153
153
///
154
154
/// withThrowingTaskGroup { group in
155
- /// group.spawn { throw SomeError() }
155
+ /// group.async { throw SomeError() }
156
156
/// try group.next()
157
157
/// }
158
158
///
@@ -194,7 +194,7 @@ public func withThrowingTaskGroup<ChildTaskResult, GroupResult>(
194
194
#endif
195
195
}
196
196
197
- /// A task group serves as storage for dynamically spawned child tasks.
197
+ /// A task group serves as storage for dynamically created child tasks.
198
198
///
199
199
/// To create a task group,
200
200
/// call the `withTaskGroup(of:returning:body:)` method.
@@ -315,8 +315,8 @@ public struct TaskGroup<ChildTaskResult> {
315
315
/// not in the order that those tasks were added to the task group.
316
316
/// For example:
317
317
///
318
- /// group.spawn { 1 }
319
- /// group.spawn { 2 }
318
+ /// group.async { 1 }
319
+ /// group.async { 2 }
320
320
///
321
321
/// print(await group.next())
322
322
/// // Prints either "2" or "1".
@@ -424,7 +424,7 @@ public struct TaskGroup<ChildTaskResult> {
424
424
// proofing, in case we'd ever have typed errors, however unlikely this may be.
425
425
// Today the throwing task group failure is simply automatically bound to `Error`.
426
426
427
- /// A task group serves as storage for dynamically spawned ,
427
+ /// A task group serves as storage for dynamically created ,
428
428
/// potentially throwing, child tasks.
429
429
///
430
430
@available ( SwiftStdlib 5 . 5 , * )
@@ -454,7 +454,7 @@ public struct ThrowingTaskGroup<ChildTaskResult, Failure: Error> {
454
454
}
455
455
}
456
456
457
- /// Spawn, unconditionally, a child task in the group.
457
+ /// Unconditionally create a child task in the group.
458
458
///
459
459
/// ### Error handling
460
460
/// Operations are allowed to `throw`, in which case the `try await next()`
@@ -550,8 +550,8 @@ public struct ThrowingTaskGroup<ChildTaskResult, Failure: Error> {
550
550
/// not in the order that those tasks were added to the task group.
551
551
/// For example:
552
552
///
553
- /// group.spawn { 1 }
554
- /// group.spawn { 2 }
553
+ /// group.async { 1 }
554
+ /// group.async { 2 }
555
555
///
556
556
/// await print(group.next())
557
557
/// // Prints either "2" or "1".
@@ -610,8 +610,8 @@ public struct ThrowingTaskGroup<ChildTaskResult, Failure: Error> {
610
610
/// not in the order that those tasks were added to the task group.
611
611
/// For example:
612
612
///
613
- /// group.spawn { 1 }
614
- /// group.spawn { 2 }
613
+ /// group.async { 1 }
614
+ /// group.async { 2 }
615
615
///
616
616
/// guard let result = await group.nextResult() else {
617
617
/// return // No task to wait on, which won't happen in this example.
@@ -710,9 +710,9 @@ extension TaskGroup: AsyncSequence {
710
710
/// which you can use to continue iterating over the group's results.
711
711
/// For example:
712
712
///
713
- /// group.spawn { 1 }
714
- /// group.spawn { throw SomeError }
715
- /// group.spawn { 2 }
713
+ /// group.async { 1 }
714
+ /// group.async { throw SomeError }
715
+ /// group.async { 2 }
716
716
///
717
717
/// do {
718
718
/// // Assuming the child tasks complete in order, this prints "1"
0 commit comments