Current state of duchain/parser

Matt Rogers mattr at kde.org
Sun May 13 14:25:26 UTC 2007


On Sunday 13 May 2007 08:25, Kris Wong wrote:
> > task #1: figure out how to fix the assert when you load a project
> > with the c++ parser enabled.
>
> I have fixed the assert, although the changes were more extensive than I
> would have liked.  Also, I am not sure how this affects the Kate team and
> what parts of DUChain they are using.
>
> There were several problems in the sanity check macros
> (ENSURE_CHAIN_READ_LOCKED and ENSURE_CHAIN_WRITE_LOCKED).  Rather than
> nitpick at these, it's easier just to say QReadWriteLock does not provide
> the functionality we need for these macros.  It's not possible to check if
> a thread has a read lock, and it's not convenient to check if a thread has
> a write lock.  That being said, there are two solutions:
>
> 1. Remove the sanity check macros - bad idea for obvious reasons.
> 2. Use a custom locking scheme.
>
> I just happened to have attached the source for #2.  You will notice that
> depending on whether it is a debug build or non-debug build, DUChainLock
> switches back to being a QReadWriteLock.  I do not think we need this; in
> fact QReadWriteLock has a bit of additional overhead with its wait
> conditions that prevent readers from getting a lock when writers are
> waiting, etc...  KDevelop only have 2 threads, this is not necessary.  I
> threw it in there just in case.  Another benefit of this lock class is that
> you can see which threads have the DUChain locked at any time.
>
> Any experts in this area please chime in.
>
> Kris Wong

A few comments in the order that I see them.

In duchainlock.h
1. No semi-colons in empty constructors. Just the brackets. Compilers have 
started to warn about this, and it's better to just avoid it all together.

2. Is there a particular reason why you used Qt::HANDLE? Everything in the 
documentation says this is pretty non portable.

3. Unline the ReadLocker and WriteLocker methods if you can. I don't know what 
the compiler does with those in debug mode, but i'd prefer to be able to 
debug it if needed.

duchainlock.cpp looks fine.
diff looks fine too.

Thanks. Nice work!
-- 
Matt




More information about the KDevelop-devel mailing list