Skip to content

Commit 5ced53e

Browse files
authored
Merge pull request #68791 from apple/ktoso-patch-15
2 parents 204d496 + e8d86e8 commit 5ced53e

File tree

1 file changed

+18
-13
lines changed

1 file changed

+18
-13
lines changed

stdlib/public/Concurrency/DiscardingTaskGroup.swift

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -414,20 +414,25 @@ extension DiscardingTaskGroup: Sendable { }
414414
/// }
415415
/// ```
416416
///
417+
/// Generally, this suits the typical use cases of a
418+
/// discarding task group well, however, if you want to prevent specific
419+
/// errors from canceling the group you can catch them inside the child
420+
/// task's body like this:
417421
///
418-
///
419-
/// Generally, this suits the typical use-cases of a
420-
/// discarding task group well, however, if you wanted to prevent specific
421-
/// errors from cancelling the group
422-
///
423-
///
424-
///
425-
///
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)