lock contention - what can we do about it?
Milian Wolff
mail at milianw.de
Sat Mar 5 19:00:02 UTC 2011
Milian Wolff, 05.03.2011:
> Hey all,
<snip>
>
> I've looked at the last one and what I notice is:
>
>
> void Set::staticRef() {
> if(!m_tree)
> return;
> m_repository->m_mutex->lock();
> SetNodeData* data = m_repository-
>
> >dataRepository.dynamicItemFromIndexSimple(m_tree);
>
> ++data->m_refCount;
> m_repository->m_mutex->unlock();
can't this be rewritten as
{
if (!m_tree)
return;
SetNodeData* data = m_repository-
>dataRepository.dynamicItemFromIndexSimple(m_tree);
QMutexLocker lock(m_repository->dataRepository.mutex());
++data->m_refCount;
}
? Or could the data node be deleted when we don't hold the lock? And why is
the original locking m_repository->m_mutex and not m_repository-
>dataRepository.mutex() ?
bye
--
Milian Wolff
mail at milianw.de
http://milianw.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kdevelop-devel/attachments/20110305/22cb4712/attachment-0001.sig>
More information about the KDevelop-devel
mailing list