Skip to content

Commit be75b85

Browse files
committed
Call out instance vs type APIs
URLs changed because DocC rules for when you need a disambiguation hash have changed since this chapter was written -- using the new spelling avoids a redirect.
1 parent ad097b3 commit be75b85

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

TSPL.docc/LanguageGuide/Concurrency.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -695,8 +695,8 @@ To let the user stop this work,
695695
without waiting for all of the tasks to complete,
696696
the tasks need check for cancellation and stop running if they are canceled.
697697
There are two ways a task can do this:
698-
by calling the [`Task.checkCancellation()`][] method,
699-
or by reading the [`Task.isCancelled`][] property.
698+
by calling the [`Task.checkCancellation()`][] type method,
699+
or by reading the [`Task.isCancelled`][`Task.isCancelled` type] type property.
700700
Calling `checkCancellation()` throws an error if the task is canceled;
701701
a throwing task can propagate the error out of the task,
702702
stopping all of the task's work.
@@ -706,7 +706,7 @@ which lets you perform clean-up work as part of stopping the task,
706706
like closing network connections and deleting temporary files.
707707

708708
[`Task.checkCancellation()`]: https://developer.apple.com/documentation/swift/task/3814826-checkcancellation
709-
[`Task.isCancelled`]: https://developer.apple.com/documentation/swift/task/3814832-iscancelled
709+
[`Task.isCancelled` type]: https://developer.apple.com/documentation/swift/task/iscancelled-swift.type.property
710710

711711
```
712712
let photos = await withTaskGroup(of: Optional<Data>.self) { group in
@@ -745,6 +745,13 @@ The code above makes several changes from the previous version:
745745

746746
[`TaskGroup.addTaskUnlessCancelled(priority:operation:)`]: https://developer.apple.com/documentation/swift/taskgroup/addtaskunlesscancelled(priority:operation:)
747747

748+
> Note:
749+
> To check whether a task has been canceled from outside that task,
750+
> use the [`Task.isCancelled`][`Task.isCancelled` instance] instance property
751+
> instead of the type property.
752+
753+
[`Task.isCancelled` instance]: https://developer.apple.com/documentation/swift/task/iscancelled-swift.property
754+
748755
For work that needs immediate notification of cancellation,
749756
use the [`Task.withTaskCancellationHandler(operation:onCancel:)`][] method.
750757
For example:

0 commit comments

Comments
 (0)