
Don G wrote:
Hi All,
For my own work in the thread-safe smart pointer arena, I have used a technique to reduce the number of mutex objects from one per object, yet minimize induced contention. The basic idea is a static pool of mutexes indexed by hashed pointers. [...]
Has anyone considered using this technique in shared_count?
Yes, I had considered a mutex pool. One problem is that boost::shared_ptr is header-only, and must remain so for backward compatibility reasons. Another problem is that a CRITICAL_SECTION needs to be dynamically initialized before use, but the initialization itself also needs synchronization. It is easy to apply this optimization to std::tr1::shared_ptr, though, since standard libraries don't need to be header-only and can initialize things before everything else. ;-)