Skip to content

HTTPCookieStorage: rewrite access to shared storage #2051

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 1 commit into from
Apr 25, 2019
Merged

HTTPCookieStorage: rewrite access to shared storage #2051

merged 1 commit into from
Apr 25, 2019

Conversation

Alexander-Ignition
Copy link
Contributor

Removed access to sharedStorage through sharedSyncQ because the static constants are initialized lazily and in a thread-safe.

@Alexander-Ignition
Copy link
Contributor Author

@swift-ci please test

1 similar comment
@spevans
Copy link
Contributor

spevans commented Apr 8, 2019

@swift-ci please test

@pushkarnk
Copy link
Member

I guess we have shared as a class var because the API doc says so. And hence the synchronisation. However, I can see that HTTPCookieStorage.shared on Darwin is get-only, but it could have an internal or private setter. In short, I can't be sure if shared should be made a constant.

@millenomi @spevans Any thoughts?

@spevans
Copy link
Contributor

spevans commented Apr 16, 2019

private(set) var should work to make the public access read-only.

@pushkarnk
Copy link
Member

@Alexander-Ignition Eager to know your thoughts too.

@Alexander-Ignition
Copy link
Contributor Author

Actually we don’t need sync code because of static is thread-safe by default. I checked no one change shared property (internally), so we don’t need public var or private(set) var. This approach with private static let and computed property for interface is common style in Foundation. NotificationCenter , FileManager , URLSession

@pushkarnk
Copy link
Member

Right, if we agree to make it a constant (class let shared), then there's no need for the sync. But the question is: given that the API doc defines it as a class var shared (though publicly read-only), should we change it to a constant? I'm not sure if the Darwin's Foundation has internal/private setters defined. I just want to be careful about the parity.

@pushkarnk
Copy link
Member

cc @ianpartridge @weissi

@spevans
Copy link
Contributor

spevans commented Apr 17, 2019

The public API only defines a getter so I don't think its a problem to use a constant internally since the API it still correct.

@pushkarnk
Copy link
Member

@swift-ci test and merge

1 similar comment
@pushkarnk
Copy link
Member

@swift-ci test and merge

@swift-ci swift-ci merged commit cc76316 into swiftlang:master Apr 25, 2019
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