mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 03:39:52 +00:00
app: run inspection reads on a Dispatch queue, not a concurrency worker (#251)
Review follow-up. The reader blocks on file I/O, and in the --smoke-inspection-order check on its gate semaphore. Inside Task.detached that blocked a Swift concurrency worker; with a single-worker cooperative pool the released newer read could not start while the older one waited, and the check timed out. The read now runs on DispatchQueue.global(qos: .userInitiated) and is bridged back with withCheckedContinuation. The request-number guard is unchanged. Signed-off-by: maridogolpeador <354308468+maridogolpeador@users.noreply.github.com>
This commit is contained in:
1 parent
ae804f0530
commit
873652d685
1 file changed
+8
-1
@@ -664,7 +664,14 @@ final class InspectionModel: ObservableObject {
|
||||
busy = true
|
||||
let reader = reader
|
||||
Task {
|
||||
let (newStatus, newReport) = await Task.detached { reader(url) }.value
|
||||
// The read blocks on file I/O (and, in `--smoke-inspection-order`, on
|
||||
// its gate), so it runs on a Dispatch queue instead of occupying a
|
||||
// Swift concurrency worker that other tasks may need.
|
||||
let (newStatus, newReport) = await withCheckedContinuation { continuation in
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
continuation.resume(returning: reader(url))
|
||||
}
|
||||
}
|
||||
finishedReads &+= 1
|
||||
// A newer selection owns the published state, including `busy`;
|
||||
// an older read that finishes late is discarded.
|
||||
|
||||
Reference in new issue
Block a user