Skip to content
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

[WWDC] Swift 6 concurrency status #291

Closed
nicoverbruggen opened this issue Jun 11, 2024 · 2 comments
Closed

[WWDC] Swift 6 concurrency status #291

nicoverbruggen opened this issue Jun 11, 2024 · 2 comments
Assignees
Labels
documentation Improvements or additions to documentation.

Comments

@nicoverbruggen
Copy link
Owner

Swift 6 includes more strict concurrency checks, I will have to investigate the impact. Running strict concurrency checks with older versions of Xcode was more strict and resulted in many warnings, so making adjustments might take some time.

@nicoverbruggen nicoverbruggen added the documentation Improvements or additions to documentation. label Jun 11, 2024
@nicoverbruggen nicoverbruggen self-assigned this Jun 11, 2024
@nicoverbruggen
Copy link
Owner Author

nicoverbruggen commented Aug 6, 2024

Let's talk broadly about the different types of warnings I am dealing with when I enable targeted concurrency checking in Xcode 15. I've done this a couple of times since strict concurrency checking was introduced as a flag.

Here's a few common issues:

  • Global variables: This one is perhaps the most obvious. I use a variety of singletons which may be accessed via multiple threads. To remedy this, I should look into adopting actors more, and see where I can avoid the global state and singletons if possible.

  • Classes that are not Sendable: The most common issue. PHP Monitor was written prior to the introduction and stability of modern concurrency features a few years ago. Making all these classes Sendable will be a major effort.

  • Closures that are not Sendable: A common issue, and this usually has to do with the fact that I've got some custom classes that aren't Sendable. Making them Sendable or looking for alternatives may be the solution here.

In particular, the way the ShellOutput class is architected at this time may cause a variety of issues. The out and err variables may not be thread-safe, so it would be wise to look into refactoring this.

Other common warnings include:

  • Capture of 'self' with non-sendable type '#Type#' in a Sendable closure
  • Non-sendable type '(#Type#, #Type#)' returned by implicitly asynchronous call to nonisolated function cannot cross actor boundary
  • Passing argument of non-sendable type '#Type#' outside of main actor-isolated context may introduce data races

It seems like a rather big undertaking to deal with all of these issues, and some rewrites may be warranted instead. I'm not versed too well when it comes to strict concurrency and with the adoption of Sendable but I will be tackling this at some point.

More on this later.

@nicoverbruggen
Copy link
Owner Author

I have no interest in adopting strict concurrency at this time. Maybe when it becomes a little bit easier to do so... much would have to change to make this change right now for very little benefit.

Also, I'm dealing with burnout and the mere thought of dealing with these sorts of "errors" and "warnings" is enough to make me close this one.

Later, not now! Never say never 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation.
Projects
None yet
Development

No branches or pull requests

1 participant