Skip to content

[Docs] NFC: Remove last remaining references to @execution attribute #80817

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/ABI/Mangling.rst
Original file line number Diff line number Diff line change
Expand Up @@ -761,7 +761,7 @@ Types
sending-result ::= 'YT' // -> sending T
#endif
#if SWIFT_RUNTIME_VERSION >= 6.2
function-isolation :== 'YC' // @execution(caller) on function type
function-isolation :== 'YC' // nonisolated(nonsending) on function type
#endif
differentiable ::= 'Yjf' // @differentiable(_forward) on function type
differentiable ::= 'Yjr' // @differentiable(reverse) on function type
Expand Down
6 changes: 3 additions & 3 deletions userdocs/diagnostics/sending-risks-data-race.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ await person.printNameConcurrently()

This happens because the `printNameConcurrently` function runs off of the main actor, and the `onMainActor` function suspends while waiting for `printNameConcurrently` to complete. While suspended, the main actor can run other tasks that still have access to `person`, which can lead to a data race.

The most common fix is to change the `async` method to run on the caller's actor using the `@execution(caller)` attribute:
The most common fix is to change the `async` method to run on the caller's actor using the `nonisolated(nonsending)` specifier:

```swift
class Person {
var name: String = ""

@execution(caller)
nonisolated(nonsending)
func printNameConcurrently() async {
print(name)
}
Expand All @@ -49,4 +49,4 @@ func onMainActor(person: Person) async {

This eliminates the risk of data-races because `printNameConcurrently` continues to run on the main actor, so all access to `person` is serialized.

You can also enable the `AsyncCallerExecution` upcoming feature to make `@execution(caller)` the default for async functions on non-`Sendable` types.
You can also enable the `AsyncCallerExecution` upcoming feature to make `nonisolated(nonsending)` the default for async functions on non-`Sendable` types.