summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNedim Hadzic <nedim.hadzic@pelagicore.com>2017-04-05 10:39:27 +0200
committerRobert Griebl <robert.griebl@pelagicore.com>2017-04-25 15:20:17 +0000
commit5b2ae01715899e62c69193429a3a432ef93db2d3 (patch)
tree32f7cf34efd86aa3f4bb9891ef1d3fe9ffd7a289
parent83c2aa32852db38447137f383f5d420b8b7d9ed9 (diff)
Move all monitor related classes to the monitor-lib
* Created new monitor-lib * Removed dependencies from window and other libs towards monitor classes. Monitor classes should depend on manager and window lib. Change-Id: Ie6f7a82b3a22808eb7414251c996072e47fd2687 Reviewed-by: Bernd Weimer <bernd.weimer@pelagicore.com>
-rw-r--r--src/manager-lib/manager-lib.pro30
-rw-r--r--src/manager-lib/processcontainer.cpp2
-rw-r--r--src/manager-lib/quicklauncher.cpp30
-rw-r--r--src/manager-lib/quicklauncher.h9
-rw-r--r--src/manager-lib/systemreader.cpp (renamed from src/manager-lib/systemmonitor_p.cpp)2
-rw-r--r--src/manager-lib/systemreader.h (renamed from src/manager-lib/systemmonitor_p.h)0
-rw-r--r--src/manager/manager.pri1
-rw-r--r--src/monitor-lib/fpsmonitor.cpp (renamed from src/manager-lib/fpsmonitor.cpp)0
-rw-r--r--src/monitor-lib/fpsmonitor.h (renamed from src/manager-lib/fpsmonitor.h)0
-rw-r--r--src/monitor-lib/memorymonitor.cpp (renamed from src/manager-lib/memorymonitor.cpp)0
-rw-r--r--src/monitor-lib/memorymonitor.h (renamed from src/manager-lib/memorymonitor.h)2
-rw-r--r--src/monitor-lib/monitor-lib.pro33
-rw-r--r--src/monitor-lib/processmonitor.cpp (renamed from src/manager-lib/processmonitor.cpp)0
-rw-r--r--src/monitor-lib/processmonitor.h (renamed from src/manager-lib/processmonitor.h)0
-rw-r--r--src/monitor-lib/processmonitor_p.cpp (renamed from src/manager-lib/processmonitor_p.cpp)0
-rw-r--r--src/monitor-lib/processmonitor_p.h (renamed from src/manager-lib/processmonitor_p.h)0
-rw-r--r--src/monitor-lib/systemmonitor.cpp (renamed from src/manager-lib/systemmonitor.cpp)38
-rw-r--r--src/monitor-lib/systemmonitor.h (renamed from src/manager-lib/systemmonitor.h)3
-rw-r--r--src/monitor-lib/xprocessmonitor.cpp (renamed from src/manager-lib/xprocessmonitor.cpp)0
-rw-r--r--src/monitor-lib/xprocessmonitor.h (renamed from src/manager-lib/xprocessmonitor.h)4
-rw-r--r--src/src.pro6
-rw-r--r--src/window-lib/windowmanager.cpp24
-rw-r--r--src/window-lib/windowmanager.h7
-rw-r--r--sync.profile2
24 files changed, 126 insertions, 67 deletions
diff --git a/src/manager-lib/manager-lib.pro b/src/manager-lib/manager-lib.pro
index eac015c6..1ff00427 100644
--- a/src/manager-lib/manager-lib.pro
+++ b/src/manager-lib/manager-lib.pro
@@ -34,14 +34,11 @@ HEADERS += \
applicationipcmanager.h \
applicationipcinterface.h \
applicationipcinterface_p.h \
- systemmonitor.h \
- systemmonitor_p.h \
- processmonitor.h \
- processmonitor_p.h \
- xprocessmonitor.h \
- memorymonitor.h \
- fpsmonitor.h \
- applicationmanager_p.h
+ applicationmanager_p.h \
+ systemreader.h \
+
+linux:HEADERS += \
+ sysfsreader.h \
!headless:HEADERS += \
fakeapplicationmanagerwindow.h \
@@ -50,9 +47,6 @@ multi-process:HEADERS += \
nativeruntime.h \
nativeruntime_p.h \
-linux:HEADERS += \
- sysfsreader.h \
-
qtHaveModule(qml):HEADERS += \
qmlinprocessruntime.h \
qmlinprocessapplicationinterface.h \
@@ -70,13 +64,10 @@ SOURCES += \
quicklauncher.cpp \
applicationipcmanager.cpp \
applicationipcinterface.cpp \
- systemmonitor.cpp \
- systemmonitor_p.cpp \
- processmonitor.cpp \
- processmonitor_p.cpp \
- xprocessmonitor.cpp \
- memorymonitor.cpp \
- fpsmonitor.cpp \
+ systemreader.cpp \
+
+linux:SOURCES += \
+ sysfsreader.cpp \
!headless:SOURCES += \
fakeapplicationmanagerwindow.cpp \
@@ -84,9 +75,6 @@ SOURCES += \
multi-process:SOURCES += \
nativeruntime.cpp \
-linux:SOURCES += \
- sysfsreader.cpp \
-
qtHaveModule(qml):SOURCES += \
qmlinprocessruntime.cpp \
qmlinprocessapplicationinterface.cpp \
diff --git a/src/manager-lib/processcontainer.cpp b/src/manager-lib/processcontainer.cpp
index 444a0b74..89ae038b 100644
--- a/src/manager-lib/processcontainer.cpp
+++ b/src/manager-lib/processcontainer.cpp
@@ -44,7 +44,7 @@
#include "containerfactory.h"
#include "application.h"
#include "processcontainer.h"
-#include "systemmonitor_p.h"
+#include "systemreader.h"
#if defined(Q_OS_UNIX)
# include <csignal>
diff --git a/src/manager-lib/quicklauncher.cpp b/src/manager-lib/quicklauncher.cpp
index 4608ebff..91d3d6c9 100644
--- a/src/manager-lib/quicklauncher.cpp
+++ b/src/manager-lib/quicklauncher.cpp
@@ -48,7 +48,7 @@
#include "containerfactory.h"
#include "runtimefactory.h"
#include "quicklauncher.h"
-#include "systemmonitor.h"
+#include "systemreader.h"
QT_BEGIN_NAMESPACE_AM
@@ -66,7 +66,11 @@ QuickLauncher::QuickLauncher(QObject *parent)
{ }
QuickLauncher::~QuickLauncher()
-{ }
+{
+ if (m_idleTimerId)
+ killTimer(m_idleTimerId);
+ delete m_idleCpu;
+}
void QuickLauncher::initialize(int runtimesPerContainer, qreal idleLoad)
{
@@ -106,20 +110,28 @@ void QuickLauncher::initialize(int runtimesPerContainer, qreal idleLoad)
}
if (idleLoad > 0) {
- SystemMonitor::instance()->setIdleLoadThreshold(idleLoad);
- m_onlyRebuildWhenIdle = true;
- connect(SystemMonitor::instance(), &SystemMonitor::idleChanged, this, &QuickLauncher::rebuild);
+ m_idleThreshold = idleLoad;
+ m_idleCpu = new CpuReader();
+ m_idleTimerId = startTimer(1000);
}
triggerRebuild();
}
-void QuickLauncher::rebuild()
+void QuickLauncher::timerEvent(QTimerEvent *te)
{
- if (m_onlyRebuildWhenIdle) {
- if (!SystemMonitor::instance()->isIdle())
- return;
+ if (te && te->timerId() == m_idleTimerId) {
+ bool nowIdle = (m_idleCpu->readLoadValue() <= m_idleThreshold);
+ if (nowIdle != m_isIdle) {
+ m_isIdle = nowIdle;
+
+ if (m_isIdle)
+ rebuild();
+ }
}
+}
+void QuickLauncher::rebuild()
+{
int todo = 0;
int done = 0;
diff --git a/src/manager-lib/quicklauncher.h b/src/manager-lib/quicklauncher.h
index b10cbf62..dde63d90 100644
--- a/src/manager-lib/quicklauncher.h
+++ b/src/manager-lib/quicklauncher.h
@@ -50,6 +50,7 @@ QT_BEGIN_NAMESPACE_AM
class AbstractContainer;
class AbstractRuntime;
+class CpuReader;
class QuickLauncher : public QObject
{
@@ -68,6 +69,9 @@ public:
public slots:
void rebuild();
+protected:
+ void timerEvent(QTimerEvent *te) override;
+
private:
QuickLauncher(QObject *parent = nullptr);
QuickLauncher(const QuickLauncher &);
@@ -86,7 +90,10 @@ private:
};
QVector<QuickLaunchEntry> m_quickLaunchPool;
- bool m_onlyRebuildWhenIdle = false;
+ int m_idleTimerId = 0;
+ CpuReader *m_idleCpu = nullptr;
+ bool m_isIdle = false;
+ qreal m_idleThreshold;
};
QT_END_NAMESPACE_AM
diff --git a/src/manager-lib/systemmonitor_p.cpp b/src/manager-lib/systemreader.cpp
index 1129ea2a..e5ab6999 100644
--- a/src/manager-lib/systemmonitor_p.cpp
+++ b/src/manager-lib/systemreader.cpp
@@ -41,7 +41,7 @@
#include <qglobal.h>
-#include "systemmonitor_p.h"
+#include "systemreader.h"
#include "global.h"
#include "logging.h"
diff --git a/src/manager-lib/systemmonitor_p.h b/src/manager-lib/systemreader.h
index 9a2a6314..9a2a6314 100644
--- a/src/manager-lib/systemmonitor_p.h
+++ b/src/manager-lib/systemreader.h
diff --git a/src/manager/manager.pri b/src/manager/manager.pri
index e62421f1..033a5103 100644
--- a/src/manager/manager.pri
+++ b/src/manager/manager.pri
@@ -12,6 +12,7 @@ QT *= \
appman_installer-private \
appman_notification-private \
appman_window-private \
+ appman_monitor-private \
CONFIG *= console
diff --git a/src/manager-lib/fpsmonitor.cpp b/src/monitor-lib/fpsmonitor.cpp
index 72c09c05..72c09c05 100644
--- a/src/manager-lib/fpsmonitor.cpp
+++ b/src/monitor-lib/fpsmonitor.cpp
diff --git a/src/manager-lib/fpsmonitor.h b/src/monitor-lib/fpsmonitor.h
index 9a873d7f..9a873d7f 100644
--- a/src/manager-lib/fpsmonitor.h
+++ b/src/monitor-lib/fpsmonitor.h
diff --git a/src/manager-lib/memorymonitor.cpp b/src/monitor-lib/memorymonitor.cpp
index 712e6f94..712e6f94 100644
--- a/src/manager-lib/memorymonitor.cpp
+++ b/src/monitor-lib/memorymonitor.cpp
diff --git a/src/manager-lib/memorymonitor.h b/src/monitor-lib/memorymonitor.h
index 61674a49..4b59eb9f 100644
--- a/src/manager-lib/memorymonitor.h
+++ b/src/monitor-lib/memorymonitor.h
@@ -44,7 +44,7 @@
#include <QAbstractListModel>
#include <QObject>
#include <QFile>
-#include <QtAppManManager/xprocessmonitor.h>
+#include "xprocessmonitor.h"
QT_BEGIN_NAMESPACE_AM
diff --git a/src/monitor-lib/monitor-lib.pro b/src/monitor-lib/monitor-lib.pro
new file mode 100644
index 00000000..62a17199
--- /dev/null
+++ b/src/monitor-lib/monitor-lib.pro
@@ -0,0 +1,33 @@
+TEMPLATE = lib
+TARGET = QtAppManMonitor
+MODULE = appman_monitor
+
+load(am-config)
+
+QT = core qml
+
+QT_FOR_PRIVATE *= \
+ appman_common-private \
+ appman_application-private \
+ appman_manager-private \
+ appman_window-private \
+
+CONFIG *= static internal_module
+
+HEADERS += \
+ systemmonitor.h \
+ processmonitor.h \
+ processmonitor_p.h \
+ xprocessmonitor.h \
+ memorymonitor.h \
+ fpsmonitor.h \
+
+SOURCES += \
+ systemmonitor.cpp \
+ processmonitor.cpp \
+ processmonitor_p.cpp \
+ xprocessmonitor.cpp \
+ memorymonitor.cpp \
+ fpsmonitor.cpp \
+
+load(qt_module)
diff --git a/src/manager-lib/processmonitor.cpp b/src/monitor-lib/processmonitor.cpp
index 09caa196..09caa196 100644
--- a/src/manager-lib/processmonitor.cpp
+++ b/src/monitor-lib/processmonitor.cpp
diff --git a/src/manager-lib/processmonitor.h b/src/monitor-lib/processmonitor.h
index 0cb8b562..0cb8b562 100644
--- a/src/manager-lib/processmonitor.h
+++ b/src/monitor-lib/processmonitor.h
diff --git a/src/manager-lib/processmonitor_p.cpp b/src/monitor-lib/processmonitor_p.cpp
index a505f62b..a505f62b 100644
--- a/src/manager-lib/processmonitor_p.cpp
+++ b/src/monitor-lib/processmonitor_p.cpp
diff --git a/src/manager-lib/processmonitor_p.h b/src/monitor-lib/processmonitor_p.h
index c9f82d96..c9f82d96 100644
--- a/src/manager-lib/processmonitor_p.h
+++ b/src/monitor-lib/processmonitor_p.h
diff --git a/src/manager-lib/systemmonitor.cpp b/src/monitor-lib/systemmonitor.cpp
index 2e8970db..bbfbbbed 100644
--- a/src/manager-lib/systemmonitor.cpp
+++ b/src/monitor-lib/systemmonitor.cpp
@@ -47,13 +47,16 @@
#include <QElapsedTimer>
#include <vector>
#include <QGuiApplication>
+#include <QQuickView>
#include "global.h"
#include "logging.h"
#include "qml-utilities.h"
#include "applicationmanager.h"
#include "systemmonitor.h"
-#include "systemmonitor_p.h"
+#include "systemreader.h"
+#include <QtAppManWindow/windowmanager.h>
+
#include "xprocessmonitor.h"
@@ -375,6 +378,7 @@ public:
int memTail = 0;
int fpsTail = 0;
QMap<QString, int> ioTails;
+ bool windowManagerConnectionCreated = false;
struct Report
{
@@ -418,6 +422,29 @@ public:
return processMonitors.last();
}
+ void registerNewView(QQuickWindow *view)
+ {
+ Q_Q(SystemMonitor);
+ if (reportFps)
+ connect(view, &QQuickWindow::frameSwapped, q, &SystemMonitor::reportFrameSwap);
+ }
+
+ void setupFpsReporting()
+ {
+ Q_Q(SystemMonitor);
+ if (!windowManagerConnectionCreated) {
+ connect(WindowManager::instance(), &WindowManager::compositorViewRegistered, this, &SystemMonitorPrivate::registerNewView);
+ windowManagerConnectionCreated = true;
+ }
+
+ for (const QQuickWindow *view : WindowManager::instance()->compositorViews()) {
+ if (reportFps)
+ connect(view, &QQuickWindow::frameSwapped, q, &SystemMonitor::reportFrameSwap);
+ else
+ disconnect(view, &QQuickWindow::frameSwapped, q, &SystemMonitor::reportFrameSwap);
+ }
+ }
+
void setupTimer(int newInterval = -1)
{
bool useNewInterval = (newInterval != -1) && (newInterval != reportingInterval);
@@ -934,6 +961,7 @@ void SystemMonitor::setFpsReportingEnabled(bool enabled)
d->fpsTail = d->count;
else
d->setupTimer();
+ d->setupFpsReporting();
emit fpsReportingEnabledChanged();
}
}
@@ -1007,19 +1035,17 @@ int SystemMonitor::reportingRange() const
/*! \internal
report a frame swap for any window. \a item is \c 0 for the System-UI
*/
-void SystemMonitor::reportFrameSwap(QObject *item)
+void SystemMonitor::reportFrameSwap()
{
Q_D(SystemMonitor);
if (!d->reportFps)
return;
- FrameTimer *frameTimer = d->frameTimer.value(item);
+ FrameTimer *frameTimer = d->frameTimer.value(nullptr);
if (!frameTimer) {
frameTimer = new FrameTimer();
- d->frameTimer.insert(item, frameTimer);
- if (item)
- connect(item, &QObject::destroyed, this, [d](QObject *o) { delete d->frameTimer.take(o); });
+ d->frameTimer.insert(nullptr, frameTimer);
}
frameTimer->newFrame();
diff --git a/src/manager-lib/systemmonitor.h b/src/monitor-lib/systemmonitor.h
index 7e249716..34c4b61f 100644
--- a/src/manager-lib/systemmonitor.h
+++ b/src/monitor-lib/systemmonitor.h
@@ -114,7 +114,7 @@ public:
int reportingRange() const;
// semi-public API: used for the WindowManager to report FPS
- void reportFrameSwap(QObject *item);
+ void reportFrameSwap();
Q_INVOKABLE QObject *getProcessMonitor(const QString &appId); // experimental only!
@@ -136,7 +136,6 @@ signals:
private:
SystemMonitor();
-
static SystemMonitor *s_instance;
SystemMonitorPrivate *d_ptr;
diff --git a/src/manager-lib/xprocessmonitor.cpp b/src/monitor-lib/xprocessmonitor.cpp
index d0f38aa6..d0f38aa6 100644
--- a/src/manager-lib/xprocessmonitor.cpp
+++ b/src/monitor-lib/xprocessmonitor.cpp
diff --git a/src/manager-lib/xprocessmonitor.h b/src/monitor-lib/xprocessmonitor.h
index 57577569..1c5aae58 100644
--- a/src/manager-lib/xprocessmonitor.h
+++ b/src/monitor-lib/xprocessmonitor.h
@@ -43,8 +43,8 @@
#include <QAbstractListModel>
#include <QObject>
-#include <QtAppManManager/fpsmonitor.h>
-#include <QtAppManManager/systemmonitor.h>
+#include "fpsmonitor.h"
+#include "systemmonitor.h"
QT_BEGIN_NAMESPACE_AM
diff --git a/src/src.pro b/src/src.pro
index 65ca2aba..77728ee9 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -16,8 +16,9 @@ notification-lib.depends = common-lib
manager-lib.depends = application-lib notification-lib plugin-interfaces
installer-lib.depends = package-lib manager-lib
window-lib.depends = manager-lib
+monitor-lib.depends = manager-lib window-lib
launcher-lib.depends = application-lib notification-lib
-manager.depends = manager-lib installer-lib window-lib
+manager.depends = manager-lib installer-lib window-lib monitor-lib
launchers.depends = launcher-lib
tools.depends = package-lib
@@ -32,10 +33,11 @@ tools.depends = package-lib
installer-lib \
window-lib \
manager \
+ monitor-lib \
launcher-lib \
launchers
- tools.depends = manager-lib installer-lib launcher-lib window-lib
+ tools.depends = manager-lib installer-lib launcher-lib window-lib monitor-lib
}
SUBDIRS += tools
diff --git a/src/window-lib/windowmanager.cpp b/src/window-lib/windowmanager.cpp
index e3795238..bf28b036 100644
--- a/src/window-lib/windowmanager.cpp
+++ b/src/window-lib/windowmanager.cpp
@@ -68,7 +68,6 @@
#include "inprocesswindow.h"
#include "dbus-policy.h"
#include "qml-utilities.h"
-#include "systemmonitor.h"
#define AM_AUTHENTICATE_DBUS(RETURN_TYPE) \
@@ -362,15 +361,6 @@ WindowManager::WindowManager(QQmlEngine *qmlEngine, const QString &waylandSocket
d->watchdogEnabled = true;
d->qmlEngine = qmlEngine;
-
- connect(SystemMonitor::instance(), &SystemMonitor::fpsReportingEnabledChanged, this, [this]() {
- for (const QQuickWindow *view : qAsConst(d->views)) {
- if (SystemMonitor::instance()->isFpsReportingEnabled())
- connect(view, &QQuickWindow::frameSwapped, this, &WindowManager::reportFps);
- else
- disconnect(view, &QQuickWindow::frameSwapped, this, &WindowManager::reportFps);
- }
- });
}
WindowManager::~WindowManager()
@@ -557,9 +547,6 @@ void WindowManager::registerCompositorView(QQuickWindow *view)
{
d->views << view;
- if (SystemMonitor::instance()->isFpsReportingEnabled())
- connect(view, &QQuickWindow::frameSwapped, this, &WindowManager::reportFps);
-
#if defined(AM_MULTI_PROCESS)
if (!ApplicationManager::instance()->isSingleProcess()) {
if (!d->waylandCompositor) {
@@ -577,6 +564,7 @@ void WindowManager::registerCompositorView(QQuickWindow *view)
#else
qCDebug(LogWayland) << "WindowManager: running in single-process mode [forced at compile-time]";
#endif
+ emit compositorViewRegistered(view);
}
void WindowManager::surfaceFullscreenChanged(QQuickItem *surfaceItem, bool isFullscreen)
@@ -844,11 +832,6 @@ QVariantMap WindowManager::windowProperties(QQuickItem *window) const
\sa ApplicationManagerWindow::setWindowProperty()
*/
-void WindowManager::reportFps()
-{
- SystemMonitor::instance()->reportFrameSwap(nullptr);
-}
-
bool WindowManager::setDBusPolicy(const QVariantMap &yamlFragment)
{
static const QVector<QByteArray> functions {
@@ -1097,6 +1080,11 @@ int WindowManagerPrivate::findWindowBySurfaceItem(QQuickItem *quickItem) const
return -1;
}
+QList<QQuickWindow *> WindowManager::compositorViews() const
+{
+ return d->views;
+}
+
#if defined(AM_MULTI_PROCESS)
int WindowManagerPrivate::findWindowByWaylandSurface(QWaylandSurface *waylandSurface) const
diff --git a/src/window-lib/windowmanager.h b/src/window-lib/windowmanager.h
index e5721d66..81176d66 100644
--- a/src/window-lib/windowmanager.h
+++ b/src/window-lib/windowmanager.h
@@ -111,6 +111,8 @@ signals:
void windowPropertyChanged(QQuickItem *window, const QString &name, const QVariant &value);
+ void compositorViewRegistered(QQuickWindow *view);
+
private slots:
void surfaceFullscreenChanged(QQuickItem *surfaceItem, bool isFullscreen);
@@ -127,12 +129,11 @@ public:
bool setDBusPolicy(const QVariantMap &yamlFragment);
+ QList<QQuickWindow *> compositorViews() const;
+
// evil hook to support in-process runtimes
void setupInProcessRuntime(QT_PREPEND_NAMESPACE_AM(AbstractRuntime) *runtime);
-private slots:
- void reportFps();
-
#if defined(AM_MULTI_PROCESS)
private slots:
void waylandSurfaceCreated(QT_PREPEND_NAMESPACE_AM(WindowSurface) *surface);
diff --git a/sync.profile b/sync.profile
index 7dfc419c..01485f1b 100644
--- a/sync.profile
+++ b/sync.profile
@@ -9,6 +9,7 @@
"QtAppManInstaller" => "$basedir/src/installer-lib",
"QtAppManLauncher" => "$basedir/src/launcher-lib",
"QtAppManPluginInterfaces" => "$basedir/src/plugin-interfaces",
+ "QtAppManMonitor" => "$basedir/src/monitor-lib",
);
%moduleheaders = ( # restrict the module headers to those found in relative path
);
@@ -18,6 +19,7 @@
# "QtAppManNotification",
# "QtAppManManager",
# "QtAppManInstaller",
+# "QtAppManMonitor"
#);
%classnames = (
);