Skip to content

Conversation

scottmarchant
Copy link
Collaborator

@scottmarchant scottmarchant commented Jul 9, 2025

Quick summary

This PR adds a focused round of new and ported tests to harden the experimental DispatchAsync package:

  • New unit tests for AsyncSemaphore and DispatchTimeInterval cover edge-cases that weren’t exercised before.
  • Ports of libdispatch reference tests (dispatch_pingpong and dispatch_group) rewritten in Swift to stress-test queue/group behaviour under concurrency.
  • Stability fixes – cleans up a few flaky assertions and makes DispatchGroup.wait publicly visible so the new tests compile.
  • Minor doc tweaks / debug-print housekeeping.

PR Dependencies

This branch is stacked on PR #1 – “Initial implementation of many GCD API’s using Swift Concurrency.”
PR #1 will need merged before this PR.

}
}

func wait() async {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure to hide whitespace changes before reviewing this. It will be a lot easier.

//
//===----------------------------------------------------------------------===//

// TODO: SM: Rename this file to AsyncSemaphoreTests (coming in next PR that adds tests)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note, this file was renamed to AsyncSemaphoreTests

Copy link
Collaborator

@JaapWijnen JaapWijnen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me! More tests! 🎉


@testable import DispatchAsync

nonisolated(unsafe) private var sharedPoolCompletionCount = 0
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this nonisolated(unsafe) bit actually required here? I thought that was only necessary when opting out of actor-isolation. I don't quite know how to reason about it when it's on a file level variable.


nonisolated(unsafe) private var sharedPoolCompletionCount = 0

@Suite("DispatchGroup Tests")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
@Suite("DispatchGroup Tests")
@Suite("AsyncSemaphore Tests")


private typealias DispatchQueue = DispatchAsync.DispatchQueue

/// Ping-Pong queue test is adapted from the test
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: fix extra space

Suggested change
/// Ping-Pong queue test is adapted from the test
/// Ping-Pong queue test is adapted from the test

@scottmarchant scottmarchant force-pushed the feat/addAdditionalTests branch from a872ad4 to ee96d84 Compare September 24, 2025 23:04
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.

4 participants