We ‘invented’ (at least we say we invented it, until someone else claims the authorship), that kind of locking, where you lock not an object itself, but what the object means in the real world (or at least in your domain). It was long part of the ano-utils project. However ano-utils is a bit bloated, so we refactored it into a small separate project, without any further dependencies to external libs.
I will not repost the explanations why it is needed and what it does, instead just a link to the github page, that explains everything: https://github.com/anotheria/idbasedlock
Lock on!