forked from qt-creator/qt-creator
Clang: Avoid duplicate jobs without changes in-between
This could happen, e.g. with this message order:
>>> updateTranslationUnitsForEditor()
add job<1>
run job<1>
>>> updateVisibleTranslationUnits(Utf8String(), {})
>>> updateVisibleTranslationUnits(path, {path})
add job<2>
finish job<1>
run job<2> -- Ops, nothing is changed but job<2> is started
This led to an outdated translation unit (e.g. wrong highlighting).
Now JobQueue checks for duplicates in the queue and checks all the
currently running jobs.
Change-Id: I05843fddcbd21ce0489681c283227c0027ded428
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -39,12 +39,17 @@ class JobQueue
|
||||
public:
|
||||
JobQueue(Documents &documents, ProjectParts &projects);
|
||||
|
||||
void add(const JobRequest &job);
|
||||
bool add(const JobRequest &job);
|
||||
|
||||
JobRequests processQueue();
|
||||
|
||||
using IsJobRunningHandler = std::function<bool(const Utf8String &)>;
|
||||
void setIsJobRunningHandler(const IsJobRunningHandler &isJobRunningHandler);
|
||||
using IsJobRunningForTranslationUnitHandler = std::function<bool(const Utf8String &)>;
|
||||
void setIsJobRunningForTranslationUnitHandler(
|
||||
const IsJobRunningForTranslationUnitHandler &isJobRunningHandler);
|
||||
|
||||
using IsJobRunningForJobRequestHandler = std::function<bool(const JobRequest &)>;
|
||||
void setIsJobRunningForJobRequestHandler(
|
||||
const IsJobRunningForJobRequestHandler &isJobRunningHandler);
|
||||
|
||||
public: // for tests
|
||||
JobRequests queue() const;
|
||||
@@ -53,6 +58,7 @@ public: // for tests
|
||||
|
||||
private:
|
||||
bool isJobRunningForTranslationUnit(const Utf8String &translationUnitId);
|
||||
bool isJobRunningForJobRequest(const JobRequest &jobRequest);
|
||||
JobRequests takeJobRequestsToRunNow();
|
||||
void removeOutDatedRequests();
|
||||
bool isJobRequestOutDated(const JobRequest &jobRequest) const;
|
||||
@@ -61,7 +67,8 @@ private:
|
||||
Documents &m_documents;
|
||||
ProjectParts &m_projectParts;
|
||||
|
||||
IsJobRunningHandler m_isJobRunningHandler;
|
||||
IsJobRunningForTranslationUnitHandler m_isJobRunningForTranslationUnitHandler;
|
||||
IsJobRunningForJobRequestHandler m_isJobRunningForJobRequestHandler;
|
||||
|
||||
JobRequests m_queue;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user