Deadlock Issue When Accessing Thread-Safe Objects within Task+withTaskGroup

For what it's worth, even in pure-GCD code this is almost always an antipattern. It breaks priority inversion avoidance, asyncing the setter usually has more overhead than the field change (the threshold where it begins to be worth it is around 1ms of work), and it degrades to non-concurrent readers under surprisingly low %s of writers. There are unusual cases where it could be worth it, but in every single case I've personally observed it was a well-meaning mistake.

6 Likes