3 ms·
almost always, the recommendation is to not embed your mutex; give it a name. foo.mu.Lock() This way you don't expose your primitives, preventing poor usage f
by sethammons 1y ago
almost always, the recommendation is to not embed your mutex; give it a name.
foo.mu.Lock()
This way you don't expose your primitives, preventing poor usage from causing a deadlock. Generally you don't want the user of your struct to have to know when or when to not lock.
- eru 1y agoAlas, locks don't compose, ie often your users will have to know about the internals when you are using locks. But it's good advice when it works.