Remix.run Logo
sethammons 4 days 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 4 days ago | parent [-]

Alas, 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.