Skip to content

Commit c14bb5b

Browse files
committed
Reduce usage of callback and dispatch methods in favor of async/await
Remove unused callback API Remove unneeded withChecked*Continuation wrappers Use async/await in more tests Remove a usage of DispatchGroup in tests Remove unused callback queues from async methods Removed unused callback methods Moved workspace and plugins to async/await
1 parent 55e284e commit c14bb5b

20 files changed

+379
-843
lines changed

Sources/Build/BuildOperation.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -566,7 +566,6 @@ public final class BuildOperation: PackageStructureDelegate, SPMBuildCore.BuildS
566566
pluginName: plugin.moduleName,
567567
toolsVersion: plugin.toolsVersion,
568568
observabilityScope: self.observabilityScope,
569-
callbackQueue: DispatchQueue.sharedConcurrent,
570569
delegate: delegate
571570
)
572571

Sources/Commands/PackageCommands/PluginCommand.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,6 @@ struct PluginCommand: AsyncSwiftCommand {
394394
fileSystem: swiftCommandState.fileSystem,
395395
modulesGraph: packageGraph,
396396
observabilityScope: swiftCommandState.observabilityScope,
397-
callbackQueue: delegateQueue,
398397
delegate: pluginDelegate
399398
)
400399

Sources/PackageRegistry/ChecksumTOFU.swift

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -67,29 +67,6 @@ struct PackageVersionChecksumTOFU {
6767
}
6868
}
6969

70-
@available(*, noasync, message: "Use the async alternative")
71-
func validateSourceArchive(
72-
registry: Registry,
73-
package: PackageIdentity.RegistryIdentity,
74-
version: Version,
75-
checksum: String,
76-
timeout: DispatchTimeInterval?,
77-
observabilityScope: ObservabilityScope,
78-
callbackQueue: DispatchQueue,
79-
completion: @escaping @Sendable (Result<Void, Error>) -> Void
80-
) {
81-
callbackQueue.asyncResult(completion) {
82-
try await self.validateSourceArchive(
83-
registry: registry,
84-
package: package,
85-
version: version,
86-
checksum: checksum,
87-
timeout: timeout,
88-
observabilityScope: observabilityScope
89-
)
90-
}
91-
}
92-
9370
private func getExpectedChecksum(
9471
registry: Registry,
9572
package: PackageIdentity.RegistryIdentity,

Sources/PackageRegistry/RegistryClient.swift

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -613,25 +613,6 @@ public final class RegistryClient: AsyncCancellable {
613613
}
614614
}
615615

616-
@available(*, deprecated, message: "Use the async alternative")
617-
public func getAvailableManifests(
618-
package: PackageIdentity,
619-
version: Version,
620-
timeout: DispatchTimeInterval? = .none,
621-
observabilityScope: ObservabilityScope,
622-
callbackQueue: DispatchQueue,
623-
completion: @escaping @Sendable (Result<[String: (toolsVersion: ToolsVersion, content: String?)], Error>) -> Void
624-
) {
625-
callbackQueue.asyncResult(completion) {
626-
try await self.getAvailableManifests(
627-
package: package,
628-
version: version,
629-
timeout: timeout,
630-
observabilityScope: observabilityScope
631-
)
632-
}
633-
}
634-
635616
public func getManifestContent(
636617
package: PackageIdentity,
637618
version: Version,

Sources/PackageRegistry/RegistryDownloadsManager.swift

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -119,23 +119,6 @@ public class RegistryDownloadsManager: AsyncCancellable {
119119
return try await task.value
120120
}
121121

122-
@available(*, noasync, message: "Use the async alternative")
123-
public func lookup(
124-
package: PackageIdentity,
125-
version: Version,
126-
observabilityScope: ObservabilityScope,
127-
callbackQueue: DispatchQueue,
128-
completion: @escaping @Sendable (Result<Basics.AbsolutePath, Error>) -> Void
129-
) {
130-
callbackQueue.asyncResult(completion) {
131-
try await self.lookup(
132-
package: package,
133-
version: version,
134-
observabilityScope: observabilityScope
135-
)
136-
}
137-
}
138-
139122
/// Cancel any outstanding requests
140123
public func cancel(deadline: DispatchTime) async throws {
141124
try await self.registryClient.cancel(deadline: deadline)

Sources/PackageRegistry/SignatureValidation.swift

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -94,33 +94,6 @@ struct SignatureValidation {
9494
return signingEntity;
9595
}
9696

97-
@available(*, noasync, message: "Use the async alternative")
98-
func validate(
99-
registry: Registry,
100-
package: PackageIdentity.RegistryIdentity,
101-
version: Version,
102-
content: Data,
103-
configuration: RegistryConfiguration.Security.Signing,
104-
timeout: DispatchTimeInterval?,
105-
fileSystem: FileSystem,
106-
observabilityScope: ObservabilityScope,
107-
callbackQueue: DispatchQueue,
108-
completion: @escaping @Sendable (Result<SigningEntity?, Error>) -> Void
109-
) {
110-
callbackQueue.asyncResult(completion) {
111-
try await self.validate(
112-
registry: registry,
113-
package: package,
114-
version: version,
115-
content: content,
116-
configuration: configuration,
117-
timeout: timeout,
118-
fileSystem: fileSystem,
119-
observabilityScope: observabilityScope
120-
)
121-
}
122-
}
123-
12497
private func getAndValidateSourceArchiveSignature(
12598
registry: Registry,
12699
package: PackageIdentity.RegistryIdentity,
@@ -350,36 +323,6 @@ struct SignatureValidation {
350323
return signingEntity;
351324
}
352325

353-
354-
@available(*, noasync, message: "Use the async alternative")
355-
func validate(
356-
registry: Registry,
357-
package: PackageIdentity.RegistryIdentity,
358-
version: Version,
359-
toolsVersion: ToolsVersion?,
360-
manifestContent: String,
361-
configuration: RegistryConfiguration.Security.Signing,
362-
timeout: DispatchTimeInterval?,
363-
fileSystem: FileSystem,
364-
observabilityScope: ObservabilityScope,
365-
callbackQueue: DispatchQueue,
366-
completion: @escaping @Sendable (Result<SigningEntity?, Error>) -> Void
367-
) {
368-
callbackQueue.asyncResult(completion) {
369-
try await self.validate(
370-
registry: registry,
371-
package: package,
372-
version: version,
373-
toolsVersion: toolsVersion,
374-
manifestContent: manifestContent,
375-
configuration: configuration,
376-
timeout: timeout,
377-
fileSystem: fileSystem,
378-
observabilityScope: observabilityScope
379-
)
380-
}
381-
}
382-
383326
private func getAndValidateManifestSignature(
384327
registry: Registry,
385328
package: PackageIdentity.RegistryIdentity,

Sources/PackageRegistry/SigningEntityTOFU.swift

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -76,26 +76,6 @@ struct PackageSigningEntityTOFU {
7676
)
7777
}
7878

79-
@available(*, noasync, message: "Use the async alternative")
80-
func validate(
81-
registry: Registry,
82-
package: PackageIdentity.RegistryIdentity,
83-
version: Version,
84-
signingEntity: SigningEntity?,
85-
observabilityScope: ObservabilityScope,
86-
completion: @escaping @Sendable (Result<Void, Error>) -> Void
87-
) {
88-
DispatchQueue.sharedConcurrent.asyncResult(completion) {
89-
try await self.validate(
90-
registry: registry,
91-
package: package,
92-
version: version,
93-
signingEntity: signingEntity,
94-
observabilityScope: observabilityScope
95-
)
96-
}
97-
}
98-
9979
private func validateSigningEntity(
10080
registry: Registry,
10181
package: PackageIdentity.RegistryIdentity,

0 commit comments

Comments
 (0)