Make yielding last progress value more reliable

This commit is contained in:
Sami Samhuri 2024-08-18 13:31:20 -07:00
parent 4966910a3b
commit aaaf227c96
No known key found for this signature in database

View file

@ -131,10 +131,15 @@ actor SampleWriter {
}
progressContinuation?.yield(1.0)
progressContinuation?.finish()
// Make sure the last progress value is yielded before returning.
await Task.yield()
await withCheckedContinuation { continuation in
progressContinuation?.onTermination = { _ in
continuation.resume(returning: ())
}
progressContinuation?.finish()
}
}
// MARK: - Setup