Why can I not writeLock after ReadLock?
Milian Wolff
mail at milianw.de
Fri Nov 12 23:40:06 UTC 2010
Hey there, esp. David.
why is this not allowed (see also duchainlock.cpp:163):
DUChainReadLocker lockRead;
/* do stuff that only requires a read lock */
...
DUChainWriteLocker lockWrite;
/* do stuff that also needs a write lock */
I assumed that a write lock is the same as a read lock, just with *additional*
checks. Since the above is not possible, I have to unlock the chain (if only
for a *very* short time) which would potentially make it possible for
declarations to get invalid (DeclarationPointer, I know - but still, it should
*not* happen to begin with).
And to have a write lock *all the time* sounds like overkill to me. The
usebuilder e.g. needs to find some declaration (read) which takes most of the
time probably, then only it has to report a new use (only write operation).
PHP did this up until now (which is of course hazardous, thanks for pointing
that out through your commit):
Declaration* dec = findDeclaration(someIdentifier);
newUse(node, dec);
i.e. no locking at all - yay :)
Now I thought let's fix it this way:
DUChainReadLocker lock;
Declaration* dec = findDeclaration(someIdentifier);
DUChainWriteLocker lockW;
newUse(node, dec);
But well, it's not working as I said above. Why?
--
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/20101113/cb2505b1/attachment.sig>
More information about the KDevelop-devel
mailing list