Skip to content

Conversation

@davedelong
Copy link
Contributor

Generally, mixing semaphores and async is a risky proposition.

This PR changes every ParsableCommand to be an AsyncParsableCommand, so they have a run() async method instead of a run() method. This means we can trivially replace the usages of DispatchSemaphore with the async versions that are created automatically by the compiler when importing closure-based methods. (Under the hood they use continuations)

I decided to change every ParsableCommand to be Async, even though it was only needed for Manage and Set. This ensures consistency between command definitions and easier async adoption in future PRs.

Methods with completion handlers, like the ones used on NSWorkspace, get imported as async methods to Swift Concurrency. This requires updating command definitions to be async.
@scriptingosx
Copy link
Owner

oh excellent catch, I have been dragging that code with the semaphores around for too long.

Question: is there a reason you are declaring all commands as asynchronous in stead of just the few that actually call the methods you have changed to async?

@scriptingosx
Copy link
Owner

Ignore the question, you did answer that...

@scriptingosx scriptingosx merged commit 9cf0158 into scriptingosx:main Jul 17, 2025
@scriptingosx
Copy link
Owner

thank you!

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.

2 participants