
Howard Hinnant escribió:
On Oct 31, 2010, at 4:49 PM, JOAQUIN M. LOPEZ MUÑOZ wrote:
[Trying my luck again with this query.]
Hi,
Boost.Threads provides a recursive mutex and a shared mutex, but no recursive *and* shared mutex. Would it be a good idea to add this to the library? How hard is it to construct a recursive shared mutex from boost::sahred_mutex (i.e. adding reentrancy to boost::shared_mutex)?
Your question is somewhat vague: Are you referring to recursive exclusive ownership, recursive shared ownership, or both?
Sorry for the fuzziness: I'm referring to recursive exclusive ownership.
I suspect recursive exclusive ownership could be managed. However I believe a recursive shared ownership would be dangerous.
[explanation on the problems with recursive shared ownership]
With recursive shared ownership on shared_mutex being a recipe for disaster, it might be confusing if the API offered recursive exclusive ownership on the shared_mutex.
Why would this be confusing? Such a recursive shared mutex would be a model of recursive mutex providing additional non-recursive shared access. I don't see any risk of confusion here, since the patterns where exclusive and shared access occur are so different. Besides, the original request stems from a real need I've got of such a beast for one of my libraries. Even if the author of Boost.Threads does not consider it interesting to include this in the library, I'd be grateful if someone can provide an implementation that I can use it internally. Thank you, Joaquín M López Muñoz Telefónica, Investitgación y Desarrollo