Skip to content

Commit 81d2d8a

Browse files
authored
Merge branch 'main' into worktree-issue-43-sampler-combinations
2 parents 2a34cde + 727a46e commit 81d2d8a

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

swift/Sources/CoreAILanguageModels/InferenceEngines/CoreAIPipelinedEngine.swift

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,17 @@ final class CoreAIPipelinedEngine: InferenceEngine, Sendable {
186186
}
187187

188188
func reset() {
189-
drain()
189+
// Cancel active generation BEFORE draining — otherwise drain() waits
190+
// forever for a producer that will never release the engine.
190191
_activeToken.withLock {
191192
$0?.cancel()
192193
$0 = nil
193194
}
194-
_generationTask.withLock { $0 = nil }
195+
_generationTask.withLock {
196+
$0?.cancel()
197+
$0 = nil
198+
}
199+
drain()
195200
guard tryAcquireEngine() else { return }
196201
defer { releaseEngine() }
197202
engine.reset()

swift/Sources/Tools/image-segmenter/ImageSegmentationRunnerMain.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ struct ImageSegmenterCLI: AsyncParsableCommand {
382382
}
383383
try writeImage(rendered, to: resolvedOutputPath)
384384
print("Output image written to \(resolvedOutputPath)")
385+
#if os(macOS)
385386
openFile(at: resolvedOutputPath)
387+
#endif
386388
}
387389

388390
// MARK: - Rendering
@@ -503,13 +505,15 @@ struct ImageSegmenterCLI: AsyncParsableCommand {
503505
}
504506
}
505507

508+
#if os(macOS)
506509
private func openFile(at path: String) {
507510
let expanded = NSString(string: path).expandingTildeInPath
508511
let process = Process()
509512
process.executableURL = URL(fileURLWithPath: "/usr/bin/open")
510513
process.arguments = [expanded]
511514
try? process.run()
512515
}
516+
#endif
513517

514518
// MARK: - Parity helpers (.npy reader + CGImage builder + metrics)
515519

0 commit comments

Comments
 (0)