Skip to content

Move PackageCollectionsProtocol to async/await #7726

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
Jun 29, 2024

Conversation

AndrewHoos
Copy link
Contributor

Move PackageCollectionsProtocol to async/await

Motivation:

async/await is easier to read and reason about then the callback APIs

Modifications:

PackageCollectionsProtocol is now expressed in terms of async methods instead of callbacks
callback to async bridge methods are removed
Replaced usage of DispatchGroup with async let
PackageMetadata init has default values for optional and array values

Result:

More readable code

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov MaxDesiatov added concurrency no functional change No user-visible functional changes included labels Jun 28, 2024
@rauhul
Copy link
Member

rauhul commented Jun 28, 2024

❤️ negative diff PRs

Copy link
Contributor

@MaxDesiatov MaxDesiatov left a comment

Choose a reason for hiding this comment

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

Thank you so much! 😊

@AndrewHoos AndrewHoos force-pushed the asyncPackageCollectionsProtocol branch from 3752418 to 30768dc Compare June 28, 2024 18:35
@AndrewHoos
Copy link
Contributor Author

/home/build-user/swiftpm/Sources/PackageCollections/PackageCollections.swift:343:22: error: cannot find 'withCheckedContinuation' in scope
341 |         let packageSearchResult = try await self.findPackage(identity: identity, location: location, collections: collections)
342 |         // then try to get more metadata from provider (optional)
343 |         return await withCheckedContinuation { continuation in
    |                      `- error: cannot find 'withCheckedContinuation' in scope
344 |             self.metadataProvider.get(identity: packageSearchResult.package.identity, location: packageSearchResult.package.location) { result, provider in
345 |                 switch result {

@AndrewHoos
Copy link
Contributor Author

Something odd with importing _Concurrency seems to break on Linux?

@MaxDesiatov
Copy link
Contributor

import _Concurrency is required when building with CMake.

@MaxDesiatov
Copy link
Contributor

@swift-ci test

@MaxDesiatov
Copy link
Contributor

@swift-ci test windows

@MaxDesiatov
Copy link
Contributor

@ahoppen could the macOS failure be related to recent SourceKit-LSP changes?

error: value of type 'SourceKitLSPOptions' has no member 'swiftSDK'

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) June 28, 2024 22:45
@AndrewHoos
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov MaxDesiatov merged commit bf0272c into main Jun 29, 2024
5 checks passed
@MaxDesiatov MaxDesiatov deleted the asyncPackageCollectionsProtocol branch June 29, 2024 03:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
concurrency no functional change No user-visible functional changes included
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants