D8999: KJob: add start(int delay) method

René J.V. Bertin noreply at phabricator.kde.org
Sat Nov 25 17:03:47 UTC 2017


rjvbb created this revision.
rjvbb added a reviewer: dfaure.
rjvbb added a project: Frameworks.
Restricted Application added a subscriber: Frameworks.

REVISION SUMMARY
  I'd like to propose a KJob method that provides a simple API to start asynchronous jobs after a delay. The default implementation would simply call `KJob::start()` via a single shot QTimer.
  
  My justification (correct me if I'm wrong...):
  Consider a cross-platform filemanager that provides a graphical directory representation which is to be kept in sync with the actual contents using a KDirWatch instance. Being cross-platform it has to contend with limitations on its use of KDirWatch and thus watches only directories. If it handles directory (re)loads with individual KJobs it will likely be starting multiple jobs for (re)loading the same folder(s) during disk-intensive operations in the parent directory (e.g. checking out a different git branch).
  In order to limit the cost and potential side-effects of such concurrent reloads it can keep track of the current job list and cancel all jobs already loading a given folder when a new reload request comes in for that directory.
  
  Starting the jobs with a delay should help reducing this cost even more: load requests that are superseded by a new request within the delay will not have cost a significant number of CPU cycles and will not have had the chance to cause side-effects.

REPOSITORY
  R244 KCoreAddons

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

AFFECTED FILES
  src/lib/jobs/kjob.cpp
  src/lib/jobs/kjob.h

To: rjvbb, dfaure
Cc: #frameworks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20171125/aef23689/attachment.html>


More information about the Kde-frameworks-devel mailing list