The current locking scheme (using shared<unique_lock>) is safer. With the new scheme we may never release the lock if something goes wrong with the caller of the functor or the functor itself, since we have dropped RAII.
A mutex is essentially the same thing as a binary semaphore and sometimes uses the
same basic implementation ... Mutexes have a concept of an owner. Only the process
that locked the mutex is supposed to unlock it. If the owner is stored by the mutex
this can be verified at runtime.
"Needs fixing" for the less safe locking scheme, looks good otherwise.
I am OK with the name, perhaps I would slightly prefer BinarySemaphore.
103 - auto const lock = std::make_ shared< std::unique_ lock<std: :mutex> >(session_ mutex); IfUnwinding lock{session_ lock};1
104 + SemaphoreUnlock
147 - auto const lock = std::make_ shared< std::unique_ lock<std: :mutex> >(session_ mutex); IfUnwinding lock{session_lock};
148 + SemaphoreUnlock
The current locking scheme (using shared< unique_ lock>) is safer. With the new scheme we may never release the lock if something goes wrong with the caller of the functor or the functor itself, since we have dropped RAII.
> I recall semaphore as a type of lock with a counter. The counter is the defining feature en.wikipedia. org/wiki/ Semaphore_ (programming)
> of a semaphore. And a quick search seems to support this:
> http://
From the bottom of the page:
A mutex is essentially the same thing as a binary semaphore and sometimes uses the
same basic implementation ... Mutexes have a concept of an owner. Only the process
that locked the mutex is supposed to unlock it. If the owner is stored by the mutex
this can be verified at runtime.
"Needs fixing" for the less safe locking scheme, looks good otherwise.