News for hackers. Stuff that matters.
Re:Chris Lattner left Swift core team by saagarjha on Wednesday February 23, 2022 @08:53PM (#30449357)
> I’ve found that avoiding deadlocks is as simple as grepping for `DispatchSemaphore|DispatchGroup` in your codebase and eliminating them with extreme prejudice.

You’d think so but then you realize that framework code you call into might decide to do this and you wouldn’t know until it deadlocked. On a 6-core iPhone 13 this is probably not going to be noticeable, but that’s probably not true on a 2-core iPhone 6s…

Re:Chris Lattner left Swift core team by ninkendo on Wednesday February 23, 2022 @10:41PM (#30449946)
Framework code you call into can block so long as it makes forward progress. Deadlocks happen if you lock a thread in the shared Concurrency thread pool, and expect some other code running in the same thread pool to do the unlocking.

But if you’re calling into framework code which is using GCD, the queues it dispatches into will be run on a separate GCD thread pool. If said framework code is using a semaphore or lock to block your calling (Concurrency) thread, then it stands to reason there’s another thread in the GCD pool which will eventually unlock it. (Or else it’s a deadlock no matter what you do.)

I haven’t come across any framework code which violates this, although maybe you’ve run into problems I haven’t.