This is a bit more proper presentation of the pseudo-patch presented in https://bugs.kde.org/show_bug.cgi?id=387238 "concurrent project directory reloading".
Probably not very useful in the current code base so I'm not expecting this to be upstreamed or to get much constructive feedback (so don't feel obliged- Watch directories exclusively as this is the only viable cross-platform compatible method unless the user set KDEV_PROJECT_INTREE_DIRWATCHING_MODE.
When watching directories, take into consideration that 1) a notification can come from a new or changed hidden file; 2) many changes can be signalled in rapid succession and 3) notifications are about changes in the given directory (= not in any of its subdirs).
Which is why I'm lumping 2 related things in the same patch:
1) prevent the CPU cost and possible other side-effects of frequent project reloads (leading to concurrent FileManagerListJobs); see #387238 for discussion when this can happen.
2) represent FileManagerListJobs in the runController. This uses a proxy KJob derative so the runController can take control over its management.
1) is, I thinkNothing can be done about 1) but the other 2 points are taken into account:
* queue reloads (with a rather arbitrary 1s cool-off delay) instead of starting them at once.
* reloads due to change notifications are marked disposable
* when another notification arrives for a directory that's already reloading (or scheduled for), *a* proper way to compress reload requestsabort the current job(s) where possible (or skip the directory if it's a subdir) before creating the new job. It cancels reloads queued or already running for the target directory or one of its subdirs and adds a cool-off delay before jobs are actually started (so they won't have used any CPU if overridden soon enough after having been scheduled)Consider only "disposable" jobs for this.
There may be better implementations, this one is least-change and has the advantage that everything continues to work when there are only sporadic reload requests.
2) was mostly a fun hack of a feature I've been missing and that now shows me why KDevelop is sometimes not as responsive as it might be. Other than that it's probably as useful as showing unnamed and/or unkillable jobs in the r* when the notification is about an already known directory the reload will be non-recursive.
- file manager list jobs are registered with the RunController.