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

Prepare for Swift 6 strict concurrency: mark NumericTypes as Sendable #120

Open
alex-vasenin opened this issue Mar 11, 2024 · 0 comments
Open

Comments

@alex-vasenin
Copy link
Contributor

Swift 6 (which expected to be released Sep 2024) is going to have strict concurrency mode to prevent data races. While (AFAIK) SwiftAA does not uses concurrency itself, its clients might want to use some of its primitives in concurrent context. I tried to compile my current project with SWIFT_STRICT_CONCURRENCY = complete and I got a lots of warnings, because I was sending primitives like JulianDay, EquatorialCoordinates, Magnitude, etc between between actor boundaries (i.e. between threads).

While those types are safe to use concurrently because they are value types, they are not explicitly declared as Sendable, which triggers the warnings. Swift 6 declares that Sendable conformance must be declared in the same file where the type is declared, so you can't do it in an extension. So we need to mark types which safe to send across actors as Sendable in the package itself. It might be a little tricky, because the package still supports iOS12.0, i.e. Swift 4.2 and we are risking breaking backward compatibility.

As a workaround it is possible to mark those types in a client app as so:
extension Magnitude: @unchecked Sendable {}

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

No branches or pull requests

1 participant