path: root/src/corelib/io/qfilesystemwatcher_inotify_p.h
diff options
authorRobin Burchell <>2011-12-29 23:56:27 +0100
committerQt by Nokia <>2012-01-10 16:19:32 +0100
commitd7ec8bf29ad2f9668c258e9c05012f4a5a0063da (patch)
treec7df9d344880d5279773f537456d5cd5d4010c9d /src/corelib/io/qfilesystemwatcher_inotify_p.h
parent3e4f7ed5ed29c907815f5bae2628e417c340efbc (diff)
Remove thread from QFileSystemWatcherEngine implementations.
These threads are actually counterproductive, as generally speaking, processing watches is not that expensive an operation, so instead, they process at full speed and can (in the case of slow processing in the thread processing the events) stack up and consume resources for no good reason. Threads also have an additional resource consumption per engine (some ~8mb of thread stack on Linux), so doing away with them is nice. A side effect of this change is that events are now effectively rate-limited by the eventloop speed of the thread they run in, so if your thread runs too slow, and you recieve a lot of events, on some platforms, events may be dropped now where in the past, they would be read by the monitor thread and turned into Qt signals (thus not visibly showing as a problem, apart from invisibly bloating memory usage). Task-number: QTBUG-20028 Change-Id: I345a56a8c709f6f778ca9a0b55b57c05229ba477 Reviewed-by: João Abecasis <> Reviewed-by: Bradley T. Hughes <>
Diffstat (limited to 'src/corelib/io/qfilesystemwatcher_inotify_p.h')
1 files changed, 4 insertions, 6 deletions
diff --git a/src/corelib/io/qfilesystemwatcher_inotify_p.h b/src/corelib/io/qfilesystemwatcher_inotify_p.h
index 7d45711006..24fc88ffeb 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify_p.h
+++ b/src/corelib/io/qfilesystemwatcher_inotify_p.h
@@ -57,8 +57,9 @@
-#include <qhash.h>
-#include <qmutex.h>
+#include <QtCore/qhash.h>
+#include <QtCore/qmutex.h>
+#include <QtCore/qsocketnotifier.h>
@@ -71,13 +72,9 @@ public:
static QInotifyFileSystemWatcherEngine *create();
- void run();
QStringList addPaths(const QStringList &paths, QStringList *files, QStringList *directories);
QStringList removePaths(const QStringList &paths, QStringList *files, QStringList *directories);
- void stop();
private Q_SLOTS:
void readFromInotify();
@@ -87,6 +84,7 @@ private:
QMutex mutex;
QHash<QString, int> pathToID;
QHash<int, QString> idToPath;
+ QSocketNotifier notifier;