diff options
author | Marco Bubke <marco.bubke@qt.io> | 2018-09-11 17:02:45 +0200 |
---|---|---|
committer | Marco Bubke <marco.bubke@qt.io> | 2018-09-24 14:33:05 +0000 |
commit | 4e6d09d8e1e9ba776ee20000d5a39b46ce2c25af (patch) | |
tree | 423e880fb98d221db033127d51917942854c7b92 /src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h | |
parent | a334650953880e29219e28bda89b4136875f3dc2 (diff) | |
download | qt-creator-4e6d09d8e1e9ba776ee20000d5a39b46ce2c25af.tar.gz |
Clang: Reuse thread based pipeline for pch creation
The pch creation so far used signal and slots but there was no explicit
pipeline. This patch is introducing the same architecture like the
refactoring plugin. It is filtering out older project parts from the
pipeline.
Change-Id: Iaa6bd2ca1272231b97ebe1f5f7b2ce8e43bc590c
Task-number: QTCREATORBUG-21111
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h')
-rw-r--r-- | src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h | 46 |
1 files changed, 39 insertions, 7 deletions
diff --git a/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h b/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h index 6a627e8865..3dc54998d0 100644 --- a/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h +++ b/src/tools/clangrefactoringbackend/source/symbolindexertaskqueue.h @@ -29,7 +29,9 @@ #include "symbolindexertask.h" #include <filepathid.h> +#include <taskschedulerinterface.h> +#include <utils/algorithm.h> #include <utils/smallstringvector.h> #include <functional> @@ -41,29 +43,59 @@ class TransactionInterface; namespace ClangBackEnd { -class SymbolIndexerTaskSchedulerInterface; class SymbolsCollectorInterface; class SymbolStorageInterface; class SymbolIndexerTaskQueue final : public SymbolIndexerTaskQueueInterface { public: - SymbolIndexerTaskQueue(SymbolIndexerTaskSchedulerInterface &symbolIndexerTaskScheduler) + using Task = SymbolIndexerTask::Callable; + + SymbolIndexerTaskQueue(TaskSchedulerInterface<Task> &symbolIndexerTaskScheduler) : m_symbolIndexerScheduler(symbolIndexerTaskScheduler) {} - void addOrUpdateTasks(std::vector<SymbolIndexerTask> &&tasks); - void removeTasks(const std::vector<int> &projectPartIds); + void addOrUpdateTasks(std::vector<SymbolIndexerTask> &&tasks) + { + auto merge = [] (SymbolIndexerTask &&first, SymbolIndexerTask &&second) { + first.callable = std::move(second.callable); + + return std::move(first); + }; + + m_tasks = Utils::setUnionMerge<std::vector<SymbolIndexerTask>>(tasks, m_tasks, merge); + } + void removeTasks(const std::vector<int> &projectPartIds) + { + auto shouldBeRemoved = [&] (const SymbolIndexerTask& task) { + return std::binary_search(projectPartIds.begin(), projectPartIds.end(), task.projectPartId); + }; + + auto newEnd = std::remove_if(m_tasks.begin(), m_tasks.end(), shouldBeRemoved); + + m_tasks.erase(newEnd, m_tasks.end()); + } + + const std::vector<SymbolIndexerTask> &tasks() const + { + return m_tasks; + } - const std::vector<SymbolIndexerTask> &tasks() const; + void processEntries() + { + uint taskCount = m_symbolIndexerScheduler.freeSlots(); - void processTasks(); + auto newEnd = std::prev(m_tasks.end(), std::min<int>(int(taskCount), int(m_tasks.size()))); + m_symbolIndexerScheduler.addTasks({std::make_move_iterator(newEnd), + std::make_move_iterator(m_tasks.end())}); + m_tasks.erase(newEnd, m_tasks.end()); + } void syncTasks(); private: std::vector<Utils::SmallString> m_projectPartIds; std::vector<SymbolIndexerTask> m_tasks; - SymbolIndexerTaskSchedulerInterface &m_symbolIndexerScheduler; + TaskSchedulerInterface<Task> &m_symbolIndexerScheduler; }; } // namespace ClangBackEnd |