Skip to content

Add discussion of main actor and @globalActor [SE-0316] #366

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 27 commits into from
May 28, 2025

Conversation

amartini51
Copy link
Member

In the past, TSPL largely depended on the API reference for the MainActor type to document its use as an attribute. However, the role of the main actor is more important in the Swift 6.2 flavor of concurrency, so we need to discuss it in the book as part of the conceptual framing.

Fixes: rdar://80904458

amartini51 added 2 commits May 6, 2025 15:04
This works around a known issue in DocC:

    swiftlang/swift-markdown#88

With the tilde underlines, @mainactor in code was being treated as a
DocC at-directive, leading to incorrect output
This reverts most of commit f3e96e4.
Removing the tildes is much better than nonbreaking spaces in code.
Copy link

@colleenish colleenish left a comment

Choose a reason for hiding this comment

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

First pass edits.

@amartini51 amartini51 marked this pull request as ready for review May 12, 2025 20:25
Edits from <rdar://150711369>

Co-authored-by: Colleen Toporek <[email protected]>
Copy link
Contributor

@rjmccall rjmccall left a comment

Choose a reason for hiding this comment

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

LGTM, other than the typo I noticed. We really need to follow this up with a deeper discussion of sendability, but this is a good first step. @hborla may have thoughts.

amartini51 and others added 2 commits May 27, 2025 14:55
With the changes from SE-0461, saying it runs as a nonisolated function
doesn't tell you anything about where the task runs.

Co-authored-by: Holly Borla <[email protected]>
Co-authored-by: John McCall <[email protected]>
@amartini51
Copy link
Member Author

Thanks @rjmccall and @hborla! I agree that Sendable needs a better conceptual discussion — we can evaluate how much of that is part of the language and goes in TSPL, and how much should go in the protocol reference (or an article that's part of the reference). Probably needs a mix of both approaches, including fleshing out this TSPL outline from when SE-0313 was accepted.

amartini51 and others added 3 commits May 28, 2025 09:40
As of SE-0442, withTaskGroup(...) can infer the child task's result
type.  Coalesced the return into a single statement because the compiler
can't infer the nil value's type in the multi-return spelling, which
would mean you still have to have the "of" and an explicit type.

Co-authored-by: Konrad Malawski <[email protected]>
@amartini51 amartini51 force-pushed the main_actor_80904458 branch from 4245af3 to 96151bd Compare May 28, 2025 16:40
@amartini51 amartini51 merged commit c9bbf1b into swiftlang:main May 28, 2025
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.

6 participants