Skip to content

Conversation

@sagar-vaholiya
Copy link

@sagar-vaholiya sagar-vaholiya commented Sep 11, 2025

This PR updates the pendingWorkComplete helper on DispatchQueue to use withCheckedContinuation instead of withUnsafeContinuation.

Why
• withCheckedContinuation enforces at runtime that the continuation is resumed exactly once, helping catch mistakes early.
• Safer default for async APIs, consistent with modern Swift concurrency best practices.
• The original code included a TODO referencing apple/swift#74206, which is now resolved.

What’s changed
• Replaced withUnsafeContinuation with withCheckedContinuation in DispatchQueue.pendingWorkComplete.
• Added a test case (DispatchQueuePendingWorkTests) to verify that the function waits for queued work to complete before returning.

How it was tested
• Ran swift test locally; new test passes.
• Verified that the continuation is resumed correctly and that the async work is completed before returning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant