[KDevelop] background parser job control (WIP)
Needs ReviewPublic

Authored by rjvbb on Sat, Mar 14, 10:30 AM.

Details

Reviewers
aaronpuchert
Group Reviewers
KDevelop
Summary

As discussed elsewhere, KDevelop doesn't currently provide a means of job control over the background parser, except when parsing a complete project.

This WIP patch introduces the simplest form of such control: a possibility to stop all background parsing processes that are not part of a project (re)parse. This includes documents that were part of such a (re)parse, got parsed, and then were rescheduled to be parsed again.

The underlying approach I used consists of an instance of a proxy/stub job controller (one per background parser instance, of which there is apparently never more than 1 at the moment). This proxy and the BGParser d class keep track of which documents are under control of the proxy so that only those jobs are cancelled at the user's request.

Most of the change is transparent outside of the BackgroundParser implementation (and doesn't cost much as far as I can tell) but I did have to add a new method to that class for client code that already implements its own job control.

Initially I just dequeued all concerned ThreadWeaver jobs but this caused intermittent crashes that looked as if they were caused by a race condition if one of those jobs was actually running. This was addressed by suspending the weaver first, which also means that the running job is allowed to finish first - not ideal but I haven't found a safe way around that yet.

As a side-effect this change also avoids queuing a reparse of a document that is already queued for parsing, which is probably a good thing.

An alternative would be to implement a "cancel all background parsing" action, but this would also need to cancel the project parse jobs and I don't really see how to do that properly without using the current approach and then sending abort commands to all JobController entries.

Diff Detail

Lint
Lint Skipped
Unit
Unit Tests Skipped
Build Status
Buildable 23827
Build 23845: arc lint + arc unit
rjvbb created this revision.Sat, Mar 14, 10:30 AM
Restricted Application added a subscriber: kdevelop-devel. · View Herald TranscriptSat, Mar 14, 10:30 AM
rjvbb requested review of this revision.Sat, Mar 14, 10:30 AM
rjvbb updated this revision to Diff 77846.Tue, Mar 17, 4:53 PM

This addresses a few issues, notably by using a queued signal to trigger url (un)registering from the requesting (weaver) thread in the thread where the JobController lives too.

The errors resulting from not doing that became apparently only when I tested this with the full-project-parse-on-load option turned on.

rjvbb set the repository for this revision to R32 KDevelop.Tue, Mar 17, 4:53 PM