Skip to content

Commit 6408317

Browse files
authored
Address concurrency warnings (#7964)
Fix the rest of the concurrency warnings caused by directly passing a continuation's resume method. Follow on to #7961
1 parent 13320b9 commit 6408317

15 files changed

+153
-88
lines changed

Sources/Basics/Concurrency/AsyncProcess.swift

+3-1
Original file line numberDiff line numberDiff line change
@@ -786,7 +786,9 @@ package final class AsyncProcess {
786786
package func waitUntilExit() async throws -> AsyncProcessResult {
787787
try await withCheckedThrowingContinuation { continuation in
788788
DispatchQueue.processConcurrent.async {
789-
self.waitUntilExit(continuation.resume(with:))
789+
self.waitUntilExit({
790+
continuation.resume(with: $0)
791+
})
790792
}
791793
}
792794
}

Sources/PackageCollections/Storage/SQLitePackageCollectionsStorage.swift

+8-4
Original file line numberDiff line numberDiff line change
@@ -625,7 +625,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
625625
try self.withDB { db in
626626
let packagesStatement = try db.prepare(query: "INSERT INTO \(Self.packagesFTSName) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?);")
627627
let targetsStatement = try db.prepare(query: "INSERT INTO \(Self.targetsFTSNameV1) VALUES (?, ?, ?, ?);")
628-
628+
629629
try db.exec(query: "BEGIN TRANSACTION;")
630630
do {
631631
// Then insert new data
@@ -679,7 +679,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
679679
try targetsStatement.reset()
680680
}
681681
}
682-
682+
683683
try db.exec(query: "COMMIT;")
684684
} catch {
685685
try db.exec(query: "ROLLBACK;")
@@ -728,7 +728,11 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
728728
}
729729
}
730730
internal func populateTargetTrie() async throws {
731-
try await withCheckedThrowingContinuation { self.populateTargetTrie(callback: $0.resume(with:)) }
731+
try await withCheckedThrowingContinuation { continuation in
732+
self.populateTargetTrie(callback: {
733+
continuation.resume(with: $0)
734+
})
735+
}
732736
}
733737

734738
internal func populateTargetTrie(callback: @escaping (Result<Void, Error>) -> Void = { _ in }) {
@@ -948,7 +952,7 @@ final class SQLitePackageCollectionsStorage: PackageCollectionsStorage, Closable
948952
);
949953
"""
950954
try db.exec(query: ftsTargetsV0)
951-
955+
952956
let ftsTargetsV1 = """
953957
CREATE VIRTUAL TABLE IF NOT EXISTS \(Self.targetsFTSNameV1) USING fts4(
954958
collection_id_blob_base64, package_id, package_repository_url, name,

Sources/PackageGraph/PackageContainer.swift

+5-2
Original file line numberDiff line numberDiff line change
@@ -189,13 +189,16 @@ public extension PackageContainerProvider {
189189
observabilityScope: ObservabilityScope,
190190
on queue: DispatchQueue
191191
) async throws -> PackageContainer {
192-
try await withCheckedThrowingContinuation {
192+
try await withCheckedThrowingContinuation { continuation in
193193
self.getContainer(
194194
for: package,
195195
updateStrategy: updateStrategy,
196196
observabilityScope: observabilityScope,
197197
on: queue,
198-
completion: $0.resume(with:))
198+
completion: {
199+
continuation.resume(with: $0)
200+
}
201+
)
199202
}
200203
}
201204
}

Sources/PackageGraph/Resolution/PubGrub/PubGrubDependencyResolver.swift

+19-9
Original file line numberDiff line numberDiff line change
@@ -252,10 +252,12 @@ public struct PubGrubDependencyResolver {
252252
}
253253

254254
let products = assignment.term.node.productFilter
255-
let container = try await withCheckedThrowingContinuation {
255+
let container = try await withCheckedThrowingContinuation { continuation in
256256
self.provider.getContainer(
257257
for: assignment.term.node.package,
258-
completion: $0.resume(with:)
258+
completion: {
259+
continuation.resume(with: $0)
260+
}
259261
)
260262
}
261263
let updatePackage = try await container.underlying.loadPackageReference(at: boundVersion)
@@ -278,8 +280,10 @@ public struct PubGrubDependencyResolver {
278280

279281
// Add overridden packages to the result.
280282
for (package, override) in state.overriddenPackages {
281-
let container = try await withCheckedThrowingContinuation {
282-
self.provider.getContainer(for: package, completion: $0.resume(with:))
283+
let container = try await withCheckedThrowingContinuation { continuation in
284+
self.provider.getContainer(for: package, completion: {
285+
continuation.resume(with: $0)
286+
})
283287
}
284288
let updatePackage = try await container.underlying.loadPackageReference(at: override.version)
285289
finalAssignments.append(.init(
@@ -340,10 +344,12 @@ public struct PubGrubDependencyResolver {
340344
// We collect all version-based dependencies in a separate structure so they can
341345
// be process at the end. This allows us to override them when there is a non-version
342346
// based (unversioned/branch-based) constraint present in the graph.
343-
let container = try await withCheckedThrowingContinuation {
347+
let container = try await withCheckedThrowingContinuation { continuation in
344348
self.provider.getContainer(
345349
for: node.package,
346-
completion: $0.resume(with:)
350+
completion: {
351+
continuation.resume(with: $0)
352+
}
347353
)
348354
}
349355
for dependency in try await container.underlying
@@ -394,8 +400,10 @@ public struct PubGrubDependencyResolver {
394400

395401
// Process dependencies of this package, similar to the first phase but branch-based dependencies
396402
// are not allowed to contain local/unversioned packages.
397-
let container = try await withCheckedThrowingContinuation {
398-
self.provider.getContainer(for: package, completion: $0.resume(with:))
403+
let container = try await withCheckedThrowingContinuation { continuation in
404+
self.provider.getContainer(for: package, completion: {
405+
continuation.resume(with: $0)
406+
})
399407
}
400408

401409
// If there is a pin for this revision-based dependency, get
@@ -676,7 +684,9 @@ public struct PubGrubDependencyResolver {
676684
for term in terms {
677685
group.addTask {
678686
let container = try await withCheckedThrowingContinuation { continuation in
679-
self.provider.getContainer(for: term.node.package, completion: continuation.resume(with:))
687+
self.provider.getContainer(for: term.node.package, completion: {
688+
continuation.resume(with: $0)
689+
})
680690
}
681691
return try await (term, container.versionCount(term.requirement))
682692
}

Sources/PackageRegistry/ChecksumTOFU.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ struct PackageVersionChecksumTOFU {
4646
observabilityScope: ObservabilityScope,
4747
callbackQueue: DispatchQueue
4848
) async throws {
49-
try await withCheckedThrowingContinuation {
49+
try await withCheckedThrowingContinuation { continuation in
5050
self.validateSourceArchive(
5151
registry: registry,
5252
package: package,
@@ -55,11 +55,13 @@ struct PackageVersionChecksumTOFU {
5555
timeout: timeout,
5656
observabilityScope: observabilityScope,
5757
callbackQueue: callbackQueue,
58-
completion: $0.resume(with:)
58+
completion: {
59+
continuation.resume(with: $0)
60+
}
5961
)
6062
}
6163
}
62-
64+
6365
@available(*, noasync, message: "Use the async alternative")
6466
func validateSourceArchive(
6567
registry: Registry,

0 commit comments

Comments
 (0)