Skip to content

Commit 382cc20

Browse files
committed
Remove confusing SWBDispatchQueue.async overload
This overload was only meant to be used in one place, and its behavior was a little confusing, since it does not actually run the work on the queue. Over time, this overload got used in a few other places due to overload resolution picking it up, and turning formerly synchronous work asynchronous. Remove it to restore the intended behavior.
1 parent e2f5506 commit 382cc20

File tree

2 files changed

+3
-16
lines changed

2 files changed

+3
-16
lines changed

Sources/SWBServiceCore/ServiceHostConnection.swift

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ final class ServiceHostConnection: @unchecked Sendable {
4646
/// Whether the queue is suspended.
4747
private let isSuspended = LockedValue(true)
4848

49-
/// The queue used to read incoming messages.
50-
private let receiveQueue: SWBQueue
51-
5249
/// The queue used to send outgoing messages.
5350
private let sendQueue: SWBQueue
5451

@@ -69,7 +66,6 @@ final class ServiceHostConnection: @unchecked Sendable {
6966
self.inputFD = inputFD
7067
self.outputFD = outputFD
7168
// The queues for the service host connection are given .userInitiated QOS (not .utility, which most queues in Swift Build have) because we don't know whether we're servicing a user interaction request. Most requests should be shunted to a background thread unless there's a reason to send a quick response at high priority.
72-
self.receiveQueue = SWBQueue(label: "SWBBuildService.ServiceHostConnection.receiveQueue", qos: .userInitiated, autoreleaseFrequency: .workItem)
7369
self.sendQueue = SWBQueue(label: "SWBBuildService.ServiceHostConnection.sendQueue", qos: .userInitiated, autoreleaseFrequency: .workItem)
7470
}
7571

@@ -136,7 +132,7 @@ final class ServiceHostConnection: @unchecked Sendable {
136132

137133
// Otherwise, launch the receive pump.
138134
isSuspended.withLock { $0 = false }
139-
receiveQueue.async {
135+
Task<Void, Never>(priority: .userInitiated) {
140136
// Read data forever.
141137
var data: [UInt8] = []
142138
let tmpBufferSize = 4096

Sources/SWBUtil/SWBDispatch.swift

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -282,17 +282,8 @@ public final class SWBQueue: Sendable {
282282
}
283283
}
284284

285-
public func async(group: SWBDispatchGroup? = nil, execute body: @escaping @Sendable () -> Void) {
286-
return queue.async(group: group?.group, execute: body)
287-
}
288-
289-
// Temporary hack until rdar://98401196 (Use Swift Concurrency for low-level IO in ServiceHostConnection) lands. This should be safe because we only ever call `async` once in the place we use this.
290-
public func async(qos: SWBQoS = .unspecified, execute work: @Sendable @escaping () async -> Void) {
291-
queue.async(group: nil, qos: qos.dispatchQoS, flags: []) {
292-
Task {
293-
await work()
294-
}
295-
}
285+
public func async(group: SWBDispatchGroup? = nil, qos: SWBQoS = .unspecified, execute body: @escaping @Sendable () -> Void) {
286+
return queue.async(group: group?.group, qos: qos.dispatchQoS, execute: body)
296287
}
297288

298289
public static func global() -> Self {

0 commit comments

Comments
 (0)