Skip to content

Commit 88db53c

Browse files
committed
Minor editorial changes.
1 parent 7fc52b1 commit 88db53c

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

TSPL.docc/LanguageGuide/Concurrency.md

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,7 +1660,7 @@ extension Person: Equatable {
16601660
You can opt out of this inference for a global-actor-isolated type
16611661
by explicitly declaring that a protocol conformance is nonisolated.
16621662
The following code example declares
1663-
a nonisolated isolated conformance to `Equatable` in an extension:
1663+
a nonisolated conformance to `Equatable` in an extension:
16641664

16651665
```swift
16661666
@MainActor
@@ -1690,10 +1690,10 @@ A conformance requirement to `Sendable` allows generic code to send parameter
16901690
values to concurrently-executing code. If generic code accepts non-`Sendable`
16911691
types, then the generic code can only use the input values from the current
16921692
isolation domain. These generic APIs can safely accept isolated conformances
1693-
and call protocol requirement as long as the caller is on the same global
1693+
and call protocol requirements as long as the caller is on the same global
16941694
actor that the conformance is isolated to. The following code has a protocol
16951695
`P`, a class `C` with a main-actor isolated conformance to `P`, and
1696-
call-sites to the `P.perform` requirement from a main-actor
1696+
calls to the `P.perform` requirement from a main-actor
16971697
task and a concurrent task:
16981698

16991699
```swift
@@ -1732,11 +1732,12 @@ from a concurrent task results in an error,
17321732
because it would allow calling the main actor isolated implementation
17331733
of `P.perform` from outside the main actor.
17341734

1735-
Generic code can check whether a value conforms to a protocol
1735+
Abstract code that uses type parameters and `any` types
1736+
can check whether a value conforms to a protocol
17361737
through dynamic casting.
17371738
The following code has a protocol `P`,
17381739
and a method `performIfP` that accepts a parameter of type `Any`
1739-
which is dynamic cast to `any P` in the function body:
1740+
which is dynamically cast to `any P` in the function body:
17401741

17411742
```swift
17421743
protocol P {
@@ -1754,11 +1755,13 @@ Isolated conformances are only safe to use
17541755
when the code is running on the global actor
17551756
that the conformance is isolated to,
17561757
so the dynamic cast only succeeds
1757-
if the dynamic cast occurs on the global actor.
1758-
If you declare a main-actor isolated conformance to `P`
1758+
if the dynamic cast occurs on that global actor.
1759+
For example, if you declare a main-actor isolated conformance to `P`
17591760
and call `performIfP` with an instance of the conforming type,
1760-
the dynamic cast will only succeed
1761-
when `performIfP` is called from the main actor:
1761+
the dynamic cast will succeed
1762+
when `performIfP` is called in a main actor task, and it
1763+
will fail when `performIfP` is called in a concurrent
1764+
task:
17621765

17631766
```swift
17641767
@MainActor class C: @MainActor P {
@@ -1790,7 +1793,7 @@ so the dynamic cast fails and `perform` is not called.
17901793

17911794
Protocol requirements can be used
17921795
through instances of conforming types and through
1793-
instances of the conforming types themselves
1796+
instances of the conforming types themselves,
17941797
called *metatype values*.
17951798
In generic code,
17961799
a conformance requirement to `Sendable` or `SendableMetatype`
@@ -1815,7 +1818,7 @@ func performConcurrently<T: P>(_ t: T) where T: Sendable {
18151818
}
18161819
```
18171820

1818-
The above code admits data races if the conformance to `P` is isolated,
1821+
The above code would admit data races if the conformance to `P` was isolated,
18191822
because the implementation of `perform`
18201823
may access global actor isolated state.
18211824
To prevent data races,

0 commit comments

Comments
 (0)