Why can I not writeLock after ReadLock?

David Nolden zwabel at googlemail.com
Sat Nov 13 12:11:50 UTC 2010

Acquiring a write-lock while already owning a read-lock is simply not
possible. There may be multiple readers at the same time, but only one
writer. If multiple readers would request a write-lock at the same
time, there would be no way to satisfy it (there may be no other
active readers while there is an active writer), thus we simply cannot
allow a reader to become a writer without unlocking in between.

In C++, I've worked around this problem by using DUChainPointer. You
could do the same. In long-term, we should find a better solution of
course, for example by using more indirect references like

Another maybe simpler work-around would be using UrlParseLock or
something similar to prevent the file which contains the declaration
from being re-parsed while holding the reference. Maybe this is the
way to go, due to efficiency.

Greetings, David

More information about the KDevelop-devel mailing list