rjvbb created this revision.
rjvbb added a reviewer: Frameworks.
rjvbb added a project: Frameworks.

REVISION SUMMARY
  KDirWatch is not current thread-safe which can cause problems when feeding or 
deleting directories in a multi-threaded approach. In addition, the class uses 
a single QFileSystemWatcher instance (`fsWatcher`) when using the `QFSWatch` 
method.
  
  Thus, as a function of which internal method is being used, multi-thread 
access should be protected with a mutex that can either be a regular class 
variable or needs to be a static class variable.
  
  Making the KDirWatch instance methods virtual allows to derive KDirWatch in a 
specialised class which adds e.g. the appropriate mutex, with minimal 
modification of existing code and without having to burden applications that 
use the class in a strictly single-threaded approach with mutex'ing overhead.

TEST PLAN
  Tested (on Mac): works as expected. Code can continue to use the result of 
functions returning a derived class pointer as `KDirWatch*` and still benefit 
from thread-safeties in the derived class.
  CD

REPOSITORY
  R244 KCoreAddons

REVISION DETAIL
  https://phabricator.kde.org/D8043

AFFECTED FILES
  src/lib/io/kdirwatch.h

To: rjvbb, #frameworks

Reply via email to