Reputation: 41509
Many of our developers don't understand what creating a shared_ptr
from a weak_ptr
has to do with locking things. By them, the term 'lock' is associated with mutexes first.
It could have been called use
or safeguard
or lease
or promote
for instance... but hey, it isn't, and it's our responsibility to learn the standard.
But to them, this is so bad an issue that another class that copied this idiom had to be renamed, causing numerous lines of code to follow the rename. Now we have sacrificed consistency with the standard for just a little intuitivity.
Does anyone know how the choice for the name lock()
was made?
Upvotes: 4
Views: 262
Reputation: 28987
It locks the shared object in memory, and prevents it being deleted.
It has nothing to do with locking a mutex or anything like that.
Upvotes: 3