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

Strict Concurrency #109

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

radianttap
Copy link

Sprinkled Sendable and @MainActor as needed.
Converted few vars into let.
Set strict-concurrency-checking to Complete.
Moved minimum deployment to iOS 15, tvOS 15, macOS 10.15 (concurrency aware versions).
Updated version info to 5.0 — I recommend to tag as such.

Turned-off BITCODE
Moved minimum deployment to iOS 15, tvOS 15, macOS 10.15
Set strict concurrency checking to Complete.
This is entirely UI-bound thus it's all in main thread.
@discardableResult
public func prepareForLayout() -> Self { return self }
}

public protocol Constrainable {
@MainActor public protocol Constrainable {
Copy link

@SomeRandomiOSDev SomeRandomiOSDev Jul 25, 2024

Choose a reason for hiding this comment

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

Strongly recommend the following instead:

Suggested change
@MainActor public protocol Constrainable {
@preconcurrency @MainActor
public protocol Constrainable {

This makes it so that existing code that doesn't yet have strict concurrency enabled can use this library version without having to make changes to their code.

@@ -36,12 +36,12 @@ extension TinyView: Constrainable {
}
}

extension LayoutGuide: Constrainable {
@MainActor extension LayoutGuide: Constrainable {

Choose a reason for hiding this comment

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

Not needed as the compiler infers @MainActor isolation for all members declared on this extension since Constrainable is isolated to the @MainActor.

Suggested change
@MainActor extension LayoutGuide: Constrainable {
extension LayoutGuide: Constrainable {

@@ -27,7 +27,7 @@
import UIKit
#endif

extension TinyView: Constrainable {
@MainActor extension TinyView: Constrainable {

Choose a reason for hiding this comment

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

Not needed as the compiler infers @MainActor isolation for all members declared on this extension since Constrainable is isolated to the @MainActor.

Suggested change
@MainActor extension TinyView: Constrainable {
extension LayoutGuide: Constrainable {

case equal = 0
case equalOrLess = -1
case equalOrGreater = 1
}

public extension Collection where Iterator.Element == Constraint {
@MainActor public extension Collection where Iterator.Element == Constraint {

Choose a reason for hiding this comment

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

Strongly recommend the following instead:

Suggested change
@MainActor public extension Collection where Iterator.Element == Constraint {
@preconcurrency @MainActor
public extension Collection where Iterator.Element == Constraint {

This makes it so that existing code that doesn't yet have strict concurrency enabled can use this library version without having to make changes to their code.

@@ -55,7 +55,7 @@ public extension Collection where Iterator.Element == Constraint {
}

#if os(OSX)
public extension Constraint {
@MainActor public extension Constraint {

Choose a reason for hiding this comment

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

Not needed since Constraint is already isolated to the @MainActor

Suggested change
@MainActor public extension Constraint {
public extension Constraint {

@@ -68,7 +68,7 @@ public extension Constraint {
}
}
#else
public extension Constraint {
@MainActor public extension Constraint {

Choose a reason for hiding this comment

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

Not needed since Constraint is already isolated to the @MainActor

Suggested change
@MainActor public extension Constraint {
public extension Constraint {

@@ -28,7 +28,7 @@
import UIKit
#endif

public extension TinyView {
@MainActor public extension TinyView {
Copy link

@SomeRandomiOSDev SomeRandomiOSDev Jul 25, 2024

Choose a reason for hiding this comment

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

Not needed since TinyView is already isolated to the @MainActor

Suggested change
@MainActor public extension TinyView {
public extension TinyView {

@@ -25,7 +25,7 @@
#if os(OSX)
import AppKit

public extension TinyView {
@MainActor public extension TinyView {
Copy link

@SomeRandomiOSDev SomeRandomiOSDev Jul 25, 2024

Choose a reason for hiding this comment

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

Not needed since TinyView is already isolated to the @MainActor

Suggested change
@MainActor public extension TinyView {
public extension TinyView {

@@ -53,7 +53,7 @@
#else
import UIKit

public extension TinyView {
@MainActor public extension TinyView {
Copy link

@SomeRandomiOSDev SomeRandomiOSDev Jul 25, 2024

Choose a reason for hiding this comment

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

Not needed since TinyView is already isolated to the @MainActor

Suggested change
@MainActor public extension TinyView {
public extension TinyView {

@@ -164,7 +164,7 @@ public struct LayoutEdge: OptionSet {
public static let none = LayoutEdge(rawValue: 1 << 6)
}

public extension TinyView {
@MainActor public extension TinyView {
Copy link

@SomeRandomiOSDev SomeRandomiOSDev Jul 25, 2024

Choose a reason for hiding this comment

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

Not needed since TinyView is already isolated to the @MainActor

Suggested change
@MainActor public extension TinyView {
public extension TinyView {

@@ -28,7 +28,7 @@
import UIKit
#endif

public extension Constrainable {
@MainActor public extension Constrainable {

Choose a reason for hiding this comment

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

Not needed since Constrainable is already isolated to the @MainActor

Suggested change
@MainActor public extension Constrainable {
public extension Constrainable {

@@ -339,7 +339,7 @@ public extension Constrainable {
}
}

public extension TinyView {
@MainActor public extension TinyView {

Choose a reason for hiding this comment

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

Not needed since TinyView is already isolated to the @MainActor

Suggested change
@MainActor public extension TinyView {
public extension TinyView {

@@ -28,7 +28,7 @@
import UIKit
#endif

extension TinyEdgeInsets {
@MainActor extension TinyEdgeInsets {

Choose a reason for hiding this comment

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

It's probably not recommended to add this since TinyEdgeInsets itself isn't isolated to the @MainActor and there's no code in any of these members that requires @MainActor isolation

@kimdv
Copy link

kimdv commented Sep 13, 2024

Any news on this or should someone else take over? 😁

@SomeRandomiOSDev
Copy link

I made all of the changes locally and was about to put up a PR myself before noticing this one. I don’t have an issue pushing my changes and opening a PR myself 🤷🏻‍♂️

@radianttap
Copy link
Author

I made all of the changes locally and was about to put up a PR myself before noticing this one. I don’t have an issue pushing my changes and opening a PR myself 🤷🏻‍♂️

Feel free and let me know, I'll close this. I have no time at the moment to work this out further.

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.

3 participants