Skip to content

Commit 62ffc9f

Browse files
authored
Fix cut off sentence and correct Throwing discarding task group docs
We cut off a sentence, this corrects that issue. resolves rdar://115519046
1 parent 8577c6b commit 62ffc9f

File tree

1 file changed

+16
-11
lines changed

1 file changed

+16
-11
lines changed

stdlib/public/Concurrency/DiscardingTaskGroup.swift

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -414,20 +414,25 @@ extension DiscardingTaskGroup: Sendable { }
414414
/// }
415415
/// ```
416416
///
417-
///
418-
///
419417
/// Generally, this suits the typical use-cases of a
420418
/// discarding task group well, however, if you wanted to prevent specific
421-
/// errors from cancelling the group
422-
///
423-
///
424-
///
419+
/// errors from cancelling the group one should catch them inside the child
420+
/// task's body like this:
425421
///
426-
/// Throwing an error in one of the child tasks of a task group
427-
/// doesn't immediately cancel the other tasks in that group.
428-
/// However,
429-
/// throwing out of the `body` of the `withThrowingTaskGroup` method does cancel
430-
/// the group, and all of its child tasks.
422+
/// ```
423+
/// try await withThrowingDiscardingTaskGroup { group in
424+
/// group.addTask {
425+
/// do {
426+
/// try boom(1)
427+
/// } catch is HarmlessError {
428+
/// return
429+
/// }
430+
/// }
431+
/// group.addTask {
432+
/// try boom(2, after: .seconds(5))
433+
/// }
434+
/// }
435+
/// ```
431436
@available(SwiftStdlib 5.9, *)
432437
@inlinable
433438
@_unsafeInheritExecutor

0 commit comments

Comments
 (0)