Skip to content

Add reference page for Sendable protocol. #42128

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 9 commits into from
Apr 22, 2022

Conversation

amartini51
Copy link
Member

Resolves rdar://87221356

@amartini51 amartini51 requested a review from DougGregor March 31, 2022 23:07
@amartini51
Copy link
Member Author

@swift-ci Please smoke test.

///
/// To satisfy the requirements of the `Sendable` protocol,
/// all of the elements of the tuple must be sendable.
/// Tuples that satisfy the requirements implicitly conform to `Sendable`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it worth mentioning the other odd case, that metatypes (e.g., Int.Type) are implicitly Sendable?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe? I'm trying to tease out what facts about "sendable" the language concept belong in TSPL, versus the facts about Sendable the protocol that belong here. I was planning to talk about metatypes in TSPL, since you can't write something like Int.Type: Sendable. However, it sounds like that discussion belongs here, because the conformance is implicit like several other things that implicitly conform to Sendable.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in c9bdda9.

///
/// ### Sendable Actors and Classes
///
/// All actor types implicitly conform to `Sendable`.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend leading with a sentence or two stating why we get implicit Sendable conformances, because it'll be informative and help with the "classes" section. Here's one idea:

Suggested change
/// All actor types implicitly conform to `Sendable`.
/// Actor types are reference types where each instance is its own concurrency domain. The actor ensures that all accesses to its mutable state are performed sequentially. Therefore, all actor types implicitly conform to `Sendable`.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added in 32e0825:

All actor types implicitly conform to Sendable because actors ensure that all access to their mutable state is performed sequentially.

@amartini51
Copy link
Member Author

@DougGregor Thanks for the review! Do the changes from today resolve the issues you highlighted?

@amartini51
Copy link
Member Author

@swift-ci Please smoke test

@amartini51 amartini51 requested a review from bjlanier April 20, 2022 20:20
@amartini51
Copy link
Member Author

@swift-ci Please smoke test and merge.

1 similar comment
@amartini51
Copy link
Member Author

@swift-ci Please smoke test and merge.

@swift-ci swift-ci merged commit c997944 into swiftlang:main Apr 22, 2022
@amartini51 amartini51 deleted the sendable_docs_87221356 branch April 22, 2022 20:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants