forked from qt-creator/qt-creator
		
	Clang: Fix canceling of clang query
Every AST unit is created and queried asynchronously, like before, but we don't wait anymore but use a timer to process new sources. So the server will not be blocked and can process other messages like cancel. Change-Id: If0e69466c78f628190f59fd32a03cab1c3a4d0a3 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
		@@ -25,9 +25,12 @@
 | 
			
		||||
 | 
			
		||||
#pragma once
 | 
			
		||||
 | 
			
		||||
#include "clangquerygatherer.h"
 | 
			
		||||
 | 
			
		||||
#include <refactoringserverinterface.h>
 | 
			
		||||
 | 
			
		||||
#include <future>
 | 
			
		||||
#include <QTimer>
 | 
			
		||||
 | 
			
		||||
#include <vector>
 | 
			
		||||
 | 
			
		||||
namespace ClangBackEnd {
 | 
			
		||||
@@ -51,18 +54,19 @@ public:
 | 
			
		||||
 | 
			
		||||
    bool isCancelingJobs() const;
 | 
			
		||||
 | 
			
		||||
    void supersedePollEventLoop(std::function<void()> &&pollEventLoop);
 | 
			
		||||
    void pollSourceRangesAndDiagnosticsForQueryMessages();
 | 
			
		||||
    void waitThatSourceRangesAndDiagnosticsForQueryMessagesAreFinished();
 | 
			
		||||
 | 
			
		||||
    bool pollTimerIsActive() const;
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    void gatherSourceRangesAndDiagnosticsForQueryMessage(std::vector<V2::FileContainer> &&sources,
 | 
			
		||||
                                                         std::vector<V2::FileContainer> &&unsaved,
 | 
			
		||||
                                                         Utils::SmallString &&query);
 | 
			
		||||
    std::size_t waitForNewSourceRangesAndDiagnosticsForQueryMessage(std::vector<Future> &futures);
 | 
			
		||||
    void gatherSourceRangesAndDiagnosticsForQueryMessages(std::vector<V2::FileContainer> &&sources,
 | 
			
		||||
                                                          std::vector<V2::FileContainer> &&unsaved,
 | 
			
		||||
                                                          Utils::SmallString &&query);
 | 
			
		||||
 | 
			
		||||
private:
 | 
			
		||||
    std::function<void()> pollEventLoop;
 | 
			
		||||
    std::atomic_bool cancelWork{false};
 | 
			
		||||
 | 
			
		||||
    ClangQueryGatherer m_gatherer;
 | 
			
		||||
    QTimer m_pollTimer;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
} // namespace ClangBackEnd
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user