This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: debug mode performance patch
On 16 November 2010 21:14, François Dumont wrote:
>
> ? ?Here is a new proposition with the deadlock issue fixed. I use auto_ptr
> to acquire it even if it is deprecated because unique_ptr is only available
> in gnu++0x mode and the library is not built in this mode, is it fine ? I
> also created a test to show the problem before the fix. In fact I even had
> to add a sleep between the 2 locks in debug.cc to reproduce the deadlock
> temporarily, it shows that the problem existed and that it has been removed
> now.
Great, thanks for checking that.
I'm not keen on the use of auto_ptr here, not because of auto_ptr
itself, I just don't think it's necessary to allocated the
scoped_locks on the heap - that adds back some of the contention
you're trying to remove! Could you not move the body of the swap
function into a separate function and call it after locking either one
or two mutexes? e.g. the do_swap function in my mail on November 7th.