> Generics could for instance have helped implement a mutex that disallows access to the memory that needs to be synchronized without locking it first.
Did any language actually do that before rust?
It's also somewhat less useful without compiler-checked ownership as you can easily have the protected data escape the lock.
Re:What could Go wrong with a mutex
by gpderetta on Wednesday November 03, 2021 @06:29AM
(#29092863)
sync-like classes [1] have been used for a long time in C++. I'm pretty sure that Stroustrup had one in his book. Of course it is always easy to subvert this kind of protection in C++ as you can easily leak references outside of the implicit critical section.
I was under the impression that Go had first party tooling for deadlock checking, something called threadanalyzer if I recall correctly.