Revision 1182037
Go back to digest for 10th October 2010Other in KDE Base
Overhaul the system-specific lock handling in KSharedDataCache.
This commit refactors the lock selection, creation, and acquisition/release
semantics in KSharedDataCache by introducing an interface for the cache locker
which is created once at KSharedDataCache creation and used from there on out.
Instead of checking the lock type every time the cache is meant to be locked or
unlocked, a quick check is done to ensure that the lock type in the cache
didn't somehow change (wrapped in KDE_ISLIKELY so hopefully essentially
instant). Profiling revealed no real change in performance.
The more important part is that it should be easier to actually add lock
handling for e.g. the Windows platform. Once Windows-native locks are supported
all we'd need is a mmap wrapper to get rudimentary working support on Windows
without having to use the kshareddatacache_win.cpp hack.
This has been tested using pthread_mutex_t and sem_t under normal usage, my
torture suite, libkgame's testbed, a KSharedDataCache benchmark from Manuel
Mommertz and a couple of games of KPat. ;)
Please let me know if I've dorked it up somehow for non-Linux/glibc.
File Changes
- /trunk/KDE/kdelibs/kdecore/util/kshareddatacache_p.h
- /trunk/KDE/kdelibs/kdecore/util/kshareddatacache.cpp