<table><tr><td style="">rjvbb updated this revision to Diff 22412.<br />rjvbb added a comment.
</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/D7995" rel="noreferrer">View Revision</a></tr></table><br /><div><div><p>This is the updated version of my proposal, rebased on the master branch.</p>

<p>To summarise:</p>

<ul class="remarkup-list">
<li class="remarkup-list-item">the KDirWatch instance is wrapped in an instance of a new ProjectWatcher class, ignoring duplicate watching requests and keeping track of the number of watched directories</li>
<li class="remarkup-list-item">the FileManagerListJob emits a watchDir signal when it visits a directory (which only happens when it's not rejected by the project filter.</li>
<li class="remarkup-list-item">the AbstractFileManagerPlugin receives this signal, adding individual directories of interest to the dirwatcher.</li>
</ul>

<p>This construction prevents race conditions that would otherwise require a global mutex, More importantly, it also "inlines" the dirwatcher population, removing the need for an atomic, uninterruptable and potentially (very) long action on the main thread, blocking the GUI (the original issue this patch is meant to address).</p>

<p>The resulting project no longer watches all items (dirs AND files) under the project directory, but only the directories that are not filtered out. I think it is thus relevant to output the number of watched directories in the benchmark I'd add something like "of N directories total" but haven't been able to figure out if that information is even available from the project or project controller.</p></div></div><br /><div><strong>CHANGES SINCE LAST UPDATE</strong><div><a href="https://phabricator.kde.org/D7995?vs=20192&id=22412" rel="noreferrer">https://phabricator.kde.org/D7995?vs=20192&id=22412</a></div></div><br /><div><strong>REVISION DETAIL</strong><div><a href="https://phabricator.kde.org/D7995" rel="noreferrer">https://phabricator.kde.org/D7995</a></div></div><br /><div><strong>AFFECTED FILES</strong><div><div>kdevplatform/project/CMakeLists.txt<br />
kdevplatform/project/abstractfilemanagerplugin.cpp<br />
kdevplatform/project/filemanagerlistjob.cpp<br />
kdevplatform/project/filemanagerlistjob.h<br />
kdevplatform/project/projectwatcher.cpp<br />
kdevplatform/project/projectwatcher.h<br />
kdevplatform/project/tests/abstractfilemanagerpluginimportbenchmark.cpp</div></div></div><br /><div><strong>To: </strong>rjvbb, KDevelop, mwolff<br /><strong>Cc: </strong>aaronpuchert, arrowdodger, kfunk, dfaure, mwolff, brauch, kdevelop-devel, njensen, geetamc, Pilzschaf, akshaydeo, surgenight<br /></div>