summaryrefslogtreecommitdiff
path: root/src/tools/clangpchmanagerbackend
diff options
context:
space:
mode:
authorMarco Bubke <marco.bubke@qt.io>2019-02-22 11:37:30 +0100
committerMarco Bubke <marco.bubke@qt.io>2019-03-04 13:40:32 +0000
commit211aef94e6ca38df921010c06995c7b7dd4785b1 (patch)
tree9ab6416d6d3984b79098815644cd83f477594fe4 /src/tools/clangpchmanagerbackend
parent3824fcbe2808649ed0726cd5f578c2fb0495b25d (diff)
downloadqt-creator-211aef94e6ca38df921010c06995c7b7dd4785b1.tar.gz
Clang: Share executeInLoop
Change-Id: Id02902e1e7abdb8b3430e7b228547c4372a424ce Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Diffstat (limited to 'src/tools/clangpchmanagerbackend')
-rw-r--r--src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp43
-rw-r--r--src/tools/clangpchmanagerbackend/source/taskscheduler.h42
2 files changed, 2 insertions, 83 deletions
diff --git a/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp b/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp
index 17af1a2bc3..89567b8d38 100644
--- a/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp
+++ b/src/tools/clangpchmanagerbackend/clangpchmanagerbackendmain.cpp
@@ -29,6 +29,7 @@
#include <clangpathwatcher.h>
#include <connectionserver.h>
#include <environment.h>
+#include <executeinloop.h>
#include <generatedfiles.h>
#include <modifiedtimechecker.h>
#include <pchcreator.h>
@@ -72,48 +73,6 @@ using ClangBackEnd::FilePathCache;
using ClangBackEnd::FilePathView;
using ClangBackEnd::TimeStamp;
-#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
-template<typename CallableType>
-class CallableEvent : public QEvent
-{
-public:
- using Callable = std::decay_t<CallableType>;
- CallableEvent(Callable &&callable)
- : QEvent(QEvent::None)
- , callable(std::move(callable))
- {}
- CallableEvent(const Callable &callable)
- : QEvent(QEvent::None)
- , callable(callable)
- {}
-
- ~CallableEvent() { callable(); }
-
-public:
- Callable callable;
-};
-
-template<typename Callable>
-void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance())
-{
- if (QThread *thread = qobject_cast<QThread *>(object))
- object = QAbstractEventDispatcher::instance(thread);
-
- QCoreApplication::postEvent(object,
- new CallableEvent<Callable>(std::forward<Callable>(callable)),
- Qt::HighEventPriority);
-}
-#else
-template<typename Callable>
-void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance())
-{
- if (QThread *thread = qobject_cast<QThread *>(object))
- object = QAbstractEventDispatcher::instance(thread);
-
- QMetaObject::invokeMethod(object, std::forward<Callable>(callable));
-}
-#endif
-
class PchManagerApplication final : public QCoreApplication
{
public:
diff --git a/src/tools/clangpchmanagerbackend/source/taskscheduler.h b/src/tools/clangpchmanagerbackend/source/taskscheduler.h
index 37fdc744a8..31d82ed2c4 100644
--- a/src/tools/clangpchmanagerbackend/source/taskscheduler.h
+++ b/src/tools/clangpchmanagerbackend/source/taskscheduler.h
@@ -30,6 +30,7 @@
#include "queueinterface.h"
#include "progresscounter.h"
+#include <executeinloop.h>
#include <processormanagerinterface.h>
#include <symbolindexertaskqueueinterface.h>
#include <symbolscollectorinterface.h>
@@ -149,47 +150,6 @@ private:
m_futures.erase(split, m_futures.end());
}
- #if QT_VERSION < QT_VERSION_CHECK(5, 10, 0)
- template <typename CallableType>
- class CallableEvent : public QEvent {
- public:
- using Callable = std::decay_t<CallableType>;
- CallableEvent(Callable &&callable)
- : QEvent(QEvent::None),
- callable(std::move(callable))
- {}
- CallableEvent(const Callable &callable)
- : QEvent(QEvent::None),
- callable(callable)
- {}
-
- ~CallableEvent()
- {
- callable();
- }
- public:
- Callable callable;
- };
-
- template <typename Callable>
- void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance()) {
- if (QThread *thread = qobject_cast<QThread*>(object))
- object = QAbstractEventDispatcher::instance(thread);
-
- QCoreApplication::postEvent(object,
- new CallableEvent<Callable>(std::forward<Callable>(callable)),
- Qt::HighEventPriority);
- }
- #else
- template <typename Callable>
- void executeInLoop(Callable &&callable, QObject *object = QCoreApplication::instance()) {
- if (QThread *thread = qobject_cast<QThread*>(object))
- object = QAbstractEventDispatcher::instance(thread);
-
- QMetaObject::invokeMethod(object, std::forward<Callable>(callable));
- }
- #endif
-
private:
std::vector<Future> m_futures;
ProcessorManager &m_processorManager;