KStringHandler: stateless/reentrant/thread-safe?
Frank Reininghaus
frank78ac at googlemail.com
Fri Oct 26 19:15:46 BST 2012
Hi everyone,
Emmanuel is currently working on implementing a parallel sort
algorithm for Dolphin to speed up loading very large folders [1].
Sorting takes quite long due to the complexity of 'natural' sorting,
which uses the comparison function KStringHandler::naturalCompare().
There are ideas how to make the comparison faster (for some
discussion, see [2]), but thanks to the elegance of QtConcurrent, the
easiest way to get a short-term performance increase is using a
parallel sort algorithm.
Obviously, the parallel sort algorithm requires that all functions
involved in comparing items, in particular
KStringHandler::naturalCompare(), are reentrant. Now the API docs of
KStringHandler [3] say that "The methods here are completely
stateless", which sounds a bit vague. Does anyone mind if I add "This
function is reentrant" to the docs of
KStringHandler::naturalCompare(), just to be sure that no
modifications can be made that would break our sort algorithm? The
code looks like it really is reentrant, even thread-safe.
Best regards,
Frank
[1] https://git.reviewboard.kde.org/r/107025/
[2] http://lists.kde.org/?t=135099603800001&r=1&w=2
[3] http://api.kde.org/4.9-api/kdelibs-apidocs/kdecore/html/namespaceKStringHandler.html
More information about the kde-core-devel
mailing list