What does "Use async-safe scoped locking instead" even mean?

AsyncSemaphore still uses a regular lock inside

I still don't know if this is due to the bad interaction between Xcode 14 and macOS before 13, or if this is strictly necessary. The people responsible for Swift concurrency won't discuss the proper way to implement a counting semaphore in a way that 1. fits their view of Swift concurrency, 2. back-deploys, 3. deals with Xcode 14 and macOS in the less painful way possible. ¯\_(ツ)_/¯

Did I mention that testing such code is hum hum tricky, since iOS simulators have a limited thread pool, and macOS faces the difficulties linked above?

When locks can be removed, AsyncSemaphore will stop using them. So far, this code is reliable to my knowledge. It answers the OP's question, and beyond (cancellation).

1 Like