Skip to content

Commit fe86091

Browse files
authored
Merge pull request #82558 from ktoso/wip-cleanup-group-docs
1 parent 5cbdcaf commit fe86091

File tree

3 files changed

+143
-80
lines changed

3 files changed

+143
-80
lines changed

stdlib/public/Concurrency/DiscardingTaskGroup.swift

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,8 @@ import Swift
2222
/// best applied in situations where the result of a child task is some form
2323
/// of side-effect.
2424
///
25-
/// A group waits for all of its child tasks
26-
/// to complete before it returns. Even cancelled tasks must run until
25+
/// A group *always* waits for all of its child tasks
26+
/// to complete before it returns. Even canceled tasks must run until
2727
/// completion before this function returns.
2828
/// Cancelled child tasks cooperatively react to cancellation and attempt
2929
/// to return as early as possible.
@@ -41,6 +41,8 @@ import Swift
4141
/// // guaranteed that slow-task has completed and the group is empty & destroyed
4242
/// ```
4343
///
44+
/// Refer to ``TaskGroup`` documentation for detailed discussion of semantics shared between all task groups.
45+
///
4446
/// Task Group Cancellation
4547
/// =======================
4648
///
@@ -65,6 +67,7 @@ import Swift
6567
/// For tasks that need to handle cancellation by throwing an error,
6668
/// use the `withThrowingDiscardingTaskGroup(returning:body:)` method instead.
6769
///
70+
/// - SeeAlso: ``TaskGroup``
6871
/// - SeeAlso: ``withThrowingDiscardingTaskGroup(returning:body:)``
6972
@available(SwiftStdlib 5.9, *)
7073
#if !hasFeature(Embedded)
@@ -131,9 +134,7 @@ public func _unsafeInheritExecutor_withDiscardingTaskGroup<GroupResult>(
131134
/// and mutation operations can't be performed
132135
/// from a concurrent execution context like a child task.
133136
///
134-
/// ### Task execution order
135-
/// Tasks added to a task group execute concurrently, and may be scheduled in
136-
/// any order.
137+
/// Refer to ``TaskGroup`` documentation for detailed discussion of semantics shared between all task groups.
137138
///
138139
/// ### Discarding behavior
139140
/// A discarding task group eagerly discards and releases its child tasks as
@@ -142,18 +143,18 @@ public func _unsafeInheritExecutor_withDiscardingTaskGroup<GroupResult>(
142143
/// be the case with a ``TaskGroup``.
143144
///
144145
/// ### Cancellation behavior
145-
/// A discarding task group becomes cancelled in one of the following ways:
146+
/// A discarding task group becomes canceled in one of the following ways:
146147
///
147148
/// - when ``cancelAll()`` is invoked on it,
148-
/// - when the ``Task`` running this task group is cancelled.
149+
/// - when the ``Task`` running this task group is canceled.
149150
///
150151
/// Since a `DiscardingTaskGroup` is a structured concurrency primitive, cancellation is
151152
/// automatically propagated through all of its child-tasks (and their child
152153
/// tasks).
153154
///
154-
/// A cancelled task group can still keep adding tasks, however they will start
155-
/// being immediately cancelled, and may act accordingly to this. To avoid adding
156-
/// new tasks to an already cancelled task group, use ``addTaskUnlessCancelled(priority:body:)``
155+
/// A canceled task group can still keep adding tasks, however they will start
156+
/// being immediately canceled, and may act accordingly to this. To avoid adding
157+
/// new tasks to an already canceled task group, use ``addTaskUnlessCancelled(priority:body:)``
157158
/// rather than the plain ``addTask(priority:body:)`` which adds tasks unconditionally.
158159
///
159160
/// For information about the language-level concurrency model that `DiscardingTaskGroup` is part of,
@@ -204,7 +205,7 @@ public struct DiscardingTaskGroup {
204205
/// If you add a task to a group after canceling the group,
205206
/// that task is canceled immediately after being added to the group.
206207
///
207-
/// Immediately cancelled child tasks should therefore cooperatively check for and
208+
/// Immediately canceled child tasks should therefore cooperatively check for and
208209
/// react to cancellation, e.g. by throwing an `CancellationError` at their
209210
/// earliest convenience, or otherwise handling the cancellation.
210211
///
@@ -245,10 +246,10 @@ extension DiscardingTaskGroup: Sendable { }
245246
/// best applied in situations where the result of a child task is some form
246247
/// of side-effect.
247248
///
248-
/// A group waits for all of its child tasks
249-
/// to complete before it returns. Even cancelled tasks must run until
249+
/// A group *always* waits for all of its child tasks
250+
/// to complete before it returns. Even canceled tasks must run until
250251
/// completion before this function returns.
251-
/// Cancelled child tasks cooperatively react to cancellation and attempt
252+
/// Canceled child tasks cooperatively react to cancellation and attempt
252253
/// to return as early as possible.
253254
/// After this function returns, the task group is always empty.
254255
///
@@ -264,6 +265,8 @@ extension DiscardingTaskGroup: Sendable { }
264265
/// // guaranteed that slow-task has completed and the group is empty & destroyed
265266
/// ```
266267
///
268+
/// Refer to ``TaskGroup`` documentation for detailed discussion of semantics shared between all task groups.
269+
///
267270
/// Task Group Cancellation
268271
/// =======================
269272
///
@@ -411,9 +414,7 @@ public func _unsafeInheritExecutor_withThrowingDiscardingTaskGroup<GroupResult>(
411414
/// and mutation operations can't be performed
412415
/// from a concurrent execution context like a child task.
413416
///
414-
/// ### Task execution order
415-
/// Tasks added to a task group execute concurrently, and may be scheduled in
416-
/// any order.
417+
/// Refer to ``TaskGroup`` documentation for detailed discussion of semantics shared between all task groups.
417418
///
418419
/// ### Discarding behavior
419420
/// A discarding task group eagerly discards and releases its child tasks as
@@ -422,20 +423,20 @@ public func _unsafeInheritExecutor_withThrowingDiscardingTaskGroup<GroupResult>(
422423
/// be the case with a ``TaskGroup``.
423424
///
424425
/// ### Cancellation behavior
425-
/// A throwing discarding task group becomes cancelled in one of the following ways:
426+
/// A throwing discarding task group becomes canceled in one of the following ways:
426427
///
427428
/// - when ``cancelAll()`` is invoked on it,
428429
/// - when an error is thrown out of the `withThrowingDiscardingTaskGroup { ... }` closure,
429-
/// - when the ``Task`` running this task group is cancelled.
430+
/// - when the ``Task`` running this task group is canceled .
430431
///
431432
/// But also, and uniquely in *discarding* task groups:
432433
/// - when *any* of its child tasks throws.
433434
///
434-
/// The group becoming cancelled automatically, and cancelling all of its child tasks,
435+
/// The group becoming canceled automatically, and cancelling all of its child tasks,
435436
/// whenever *any* child task throws an error is a behavior unique to discarding task groups,
436437
/// because achieving such semantics is not possible otherwise, due to the missing `next()` method
437438
/// on discarding groups. Accumulating task groups can implement this by manually polling `next()`
438-
/// and deciding to `cancelAll()` when they decide an error should cause the group to become cancelled,
439+
/// and deciding to `cancelAll()` when they decide an error should cause the group to become canceled,
439440
/// however a discarding group cannot poll child tasks for results and therefore assumes that child
440441
/// task throws are an indication of a group wide failure. In order to avoid such behavior,
441442
/// use a ``DiscardingTaskGroup`` instead of a throwing one, or catch specific errors in
@@ -445,9 +446,9 @@ public func _unsafeInheritExecutor_withThrowingDiscardingTaskGroup<GroupResult>(
445446
/// automatically propagated through all of its child-tasks (and their child
446447
/// tasks).
447448
///
448-
/// A cancelled task group can still keep adding tasks, however they will start
449-
/// being immediately cancelled, and may act accordingly to this. To avoid adding
450-
/// new tasks to an already cancelled task group, use ``addTaskUnlessCancelled(priority:body:)``
449+
/// A canceled task group can still keep adding tasks, however they will start
450+
/// being immediately canceled, and may act accordingly to this. To avoid adding
451+
/// new tasks to an already canceled task group, use ``addTaskUnlessCancelled(priority:body:)``
451452
/// rather than the plain ``addTask(priority:body:)`` which adds tasks unconditionally.
452453
///
453454
/// For information about the language-level concurrency model that `DiscardingTaskGroup` is part of,
@@ -496,7 +497,7 @@ public struct ThrowingDiscardingTaskGroup<Failure: Error> {
496497
/// If you add a task to a group after canceling the group,
497498
/// that task is canceled immediately after being added to the group.
498499
///
499-
/// Immediately cancelled child tasks should therefore cooperatively check for and
500+
/// Immediately canceled child tasks should therefore cooperatively check for and
500501
/// react to cancellation, e.g. by throwing an `CancellationError` at their
501502
/// earliest convenience, or otherwise handling the cancellation.
502503
///

0 commit comments

Comments
 (0)