Skip to content

[Concurrency] Add explicit test for dispatchMain() DispatchQueue.main.async + asserting #73564

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 13, 2024

Conversation

ktoso
Copy link
Contributor

@ktoso ktoso commented May 10, 2024

Add another explicit test for using dispatchMain() and asserting the isolation.

The debug output here would be (prints not comitted);

Actor.cpp:385 expected is main
Actor.cpp:390 IS NOT on main thread
Actor.cpp:408 call checkIsolated did not crash

and it works even if the queue isn't implementing SerialExecutor because:

static void swift_task_checkIsolatedImpl(SerialExecutorRef executor) {
  // If it is the main executor, compare with the Main queue
  if (executor.isMainExecutor()) {
    dispatch_assert_queue(dispatch_get_main_queue());
    return;
  }

// before we actually go in and call `checkIsolated`

Did we miss some other edge case?

Related to rdar://110210541

@ktoso
Copy link
Contributor Author

ktoso commented May 10, 2024

@swift-ci please smoke test

@ktoso ktoso requested review from mikeash and PriyaAvhad May 10, 2024 06:57
@ktoso ktoso merged commit 477f37f into swiftlang:main May 13, 2024
@ktoso ktoso deleted the wip-extra-test branch May 13, 2024 06:39
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