3 ms·
gcd still doesn't enable you to properly create mutexes or the equivalent of @synchronized. Concurrency is still a work in progress in swift, in the most funda
by bsaul 9y ago
gcd still doesn't enable you to properly create mutexes or the equivalent of @synchronized.
Concurrency is still a work in progress in swift, in the most fundamental levels.
- gilgoomesh 9y agolet mutex = DispatchQueue(label: “”) mutex.sync { /* protected code here */ } As for @sychronized, the devs have talked about why it is flawed (requires double locking) and why use should always use a manual mutex scope.
- bsaul 9y agoCreating a closure and scheduling it on a queue seems like a pretty heavyweight way to ensure exclusive access (see https://www.cocoawithlove.com/blog/2016/06/02/threads-and-mutexes.html#mutexes-and-closure-capture-pitfalls https://www.cocoawithlove.com/blog/2016/06/02/threads-and-mu... for more). EDIT: aren't you the one that wrote this article ? :))