<table><tr><td style="">rjvbb created this revision.<br />rjvbb added reviewers: KDevelop, aaronpuchert.<br />rjvbb added a project: KDevelop.<br />Herald added a subscriber: kdevelop-devel.<br />rjvbb requested review of this revision.
</td><a style="text-decoration: none; padding: 4px 8px; margin: 0 8px 8px; float: right; color: #464C5C; font-weight: bold; border-radius: 3px; background-color: #F7F7F9; background-image: linear-gradient(to bottom,#fff,#f1f0f1); display: inline-block; border: 1px solid rgba(71,87,120,.2);" href="https://phabricator.kde.org/D28043">View Revision</a></tr></table><br /><div><strong>REVISION SUMMARY</strong><div><p>As discussed elsewhere, KDevelop doesn't currently provide a means of job control over the background parser, except when parsing a complete project.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p>

<p>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.</p></div></div><br /><div><strong>REPOSITORY</strong><div><div>R32 KDevelop</div></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D28043">https://phabricator.kde.org/D28043</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>kdevplatform/language/backgroundparser/backgroundparser.cpp<br />
kdevplatform/language/backgroundparser/backgroundparser.h<br />
kdevplatform/language/backgroundparser/parseprojectjob.cpp</div></div></div><br /><div><strong>To: </strong>rjvbb, KDevelop, aaronpuchert<br /><strong>Cc: </strong>kdevelop-devel, develoot, hmitonneau, christiant, glebaccon, domson, antismap, iodelay, alexeymin, geetamc, Pilzschaf, akshaydeo, surgenight, arrowd<br /></div>