File tree Expand file tree Collapse file tree 1 file changed +18
-13
lines changed
stdlib/public/Concurrency Expand file tree Collapse file tree 1 file changed +18
-13
lines changed Original file line number Diff line number Diff 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
You can’t perform that action at this time.
0 commit comments