fewer locks in RunnerContext

Aaron J. Seigo aseigo at kde.org
Wed May 7 18:51:17 CEST 2008


hi all..

the data members of RunnerContext are now read-only for all intents and 
purposes: when the query term is set, the data is first detached creating a 
new set of data members to operate on. the RunnerContext API enforces this 
pattern.

this means that we *should* be able to get rid of a number of locks 
completely, such as the read lock in query() -> QString is reentrant, the 
data is never being written to ... so no lock is needed.

really, the only thing we need to lock aggressively is access to matches list.

moreover, due to this pattern, the search term passed into addMatches will 
*always* match whatever came out of query() and so it is completely 
unecessary to check the value of the term passed into addMatches. at one 
point i put in some asserts to test this theory and they were never hit no 
matter what i tried to do.

if this does work out, i'll change addMatches and addMatch to not take a 
QString at all. that will require changing all the runners, however, so i'd 
like to get this patch peer reviewed, tested and in svn before going down 
that path.

the attached patch implements the above, and shows nicely how the shared dptr 
approach can help us get RunnerMatch as clock to lockless as possible.

i've been running with it since yesterday and things seem to behave nicely.

-- 
Aaron J. Seigo
humru othro a kohnu se
GPG Fingerprint: 8B8B 2209 0C6F 7C47 B1EA  EE75 D6B7 2EB1 A7F1 DB43

KDE core developer sponsored by Trolltech
-------------- next part --------------
A non-text attachment was scrubbed...
Name: almost_lockless_context.diff
Type: text/x-diff
Size: 1911 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080507/1ed71996/attachment.bin 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 194 bytes
Desc: This is a digitally signed message part.
Url : http://mail.kde.org/pipermail/panel-devel/attachments/20080507/1ed71996/attachment.pgp 


More information about the Panel-devel mailing list