Remove unnecessary QMutexes in QFileSystemWatcher implementations
The polling, inotify, and kqueue implementations are no longer threaded, and as such, do not need mutexes to protect their internal data (since QFileSystemWatcher itself is not documented as a thread-safe API). The Windows implementation is unchanged as it uses multiple threads explicitly. Change-Id: Ia82510397e576bf704ce3aed3d776b58b39f7ff3 Reviewed-by: Robin Burchell <robin+qt@viroteck.net> Reviewed-by: João Abecasis <joao.abecasis@nokia.com>
This commit is contained in:
parent
d6e0306a90
commit
93a466c6fc
@ -48,7 +48,6 @@
|
|||||||
#include <qdebug.h>
|
#include <qdebug.h>
|
||||||
#include <qdir.h>
|
#include <qdir.h>
|
||||||
#include <qfileinfo.h>
|
#include <qfileinfo.h>
|
||||||
#include <qmutex.h>
|
|
||||||
#include <qset.h>
|
#include <qset.h>
|
||||||
#include <qtimer.h>
|
#include <qtimer.h>
|
||||||
|
|
||||||
|
@ -245,8 +245,6 @@ QStringList QInotifyFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||||||
QStringList *files,
|
QStringList *files,
|
||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
|
|
||||||
QStringList p = paths;
|
QStringList p = paths;
|
||||||
QMutableListIterator<QString> it(p);
|
QMutableListIterator<QString> it(p);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@ -303,8 +301,6 @@ QStringList QInotifyFileSystemWatcherEngine::removePaths(const QStringList &path
|
|||||||
QStringList *files,
|
QStringList *files,
|
||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
|
|
||||||
QStringList p = paths;
|
QStringList p = paths;
|
||||||
QMutableListIterator<QString> it(p);
|
QMutableListIterator<QString> it(p);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@ -331,8 +327,6 @@ QStringList QInotifyFileSystemWatcherEngine::removePaths(const QStringList &path
|
|||||||
|
|
||||||
void QInotifyFileSystemWatcherEngine::readFromInotify()
|
void QInotifyFileSystemWatcherEngine::readFromInotify()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
|
|
||||||
// qDebug() << "QInotifyFileSystemWatcherEngine::readFromInotify";
|
// qDebug() << "QInotifyFileSystemWatcherEngine::readFromInotify";
|
||||||
|
|
||||||
int buffSize = 0;
|
int buffSize = 0;
|
||||||
|
@ -81,7 +81,6 @@ private Q_SLOTS:
|
|||||||
private:
|
private:
|
||||||
QInotifyFileSystemWatcherEngine(int fd);
|
QInotifyFileSystemWatcherEngine(int fd);
|
||||||
int inotifyFd;
|
int inotifyFd;
|
||||||
QMutex mutex;
|
|
||||||
QHash<QString, int> pathToID;
|
QHash<QString, int> pathToID;
|
||||||
QHash<int, QString> idToPath;
|
QHash<int, QString> idToPath;
|
||||||
QSocketNotifier notifier;
|
QSocketNotifier notifier;
|
||||||
|
@ -98,9 +98,6 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
QStringList p = paths;
|
QStringList p = paths;
|
||||||
{
|
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
|
|
||||||
QMutableListIterator<QString> it(p);
|
QMutableListIterator<QString> it(p);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
QString path = it.next();
|
QString path = it.next();
|
||||||
@ -168,7 +165,6 @@ QStringList QKqueueFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||||||
pathToID.insert(path, id);
|
pathToID.insert(path, id);
|
||||||
idToPath.insert(id, path);
|
idToPath.insert(id, path);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -179,8 +175,6 @@ QStringList QKqueueFileSystemWatcherEngine::removePaths(const QStringList &paths
|
|||||||
{
|
{
|
||||||
bool isEmpty;
|
bool isEmpty;
|
||||||
QStringList p = paths;
|
QStringList p = paths;
|
||||||
{
|
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
if (pathToID.isEmpty())
|
if (pathToID.isEmpty())
|
||||||
return p;
|
return p;
|
||||||
|
|
||||||
@ -201,7 +195,6 @@ QStringList QKqueueFileSystemWatcherEngine::removePaths(const QStringList &paths
|
|||||||
files->removeAll(path);
|
files->removeAll(path);
|
||||||
}
|
}
|
||||||
isEmpty = pathToID.isEmpty();
|
isEmpty = pathToID.isEmpty();
|
||||||
}
|
|
||||||
|
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
@ -224,7 +217,6 @@ void QKqueueFileSystemWatcherEngine::readFromKqueue()
|
|||||||
int fd = kev.ident;
|
int fd = kev.ident;
|
||||||
|
|
||||||
DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter;
|
DEBUG() << "QKqueueFileSystemWatcherEngine: processing kevent" << kev.ident << kev.filter;
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
|
|
||||||
int id = fd;
|
int id = fd;
|
||||||
QString path = idToPath.value(id);
|
QString path = idToPath.value(id);
|
||||||
|
@ -85,7 +85,6 @@ private:
|
|||||||
|
|
||||||
int kqfd;
|
int kqfd;
|
||||||
|
|
||||||
QMutex mutex;
|
|
||||||
QHash<QString, int> pathToID;
|
QHash<QString, int> pathToID;
|
||||||
QHash<int, QString> idToPath;
|
QHash<int, QString> idToPath;
|
||||||
QSocketNotifier notifier;
|
QSocketNotifier notifier;
|
||||||
|
@ -54,7 +54,6 @@ QStringList QPollingFileSystemWatcherEngine::addPaths(const QStringList &paths,
|
|||||||
QStringList *files,
|
QStringList *files,
|
||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
QStringList p = paths;
|
QStringList p = paths;
|
||||||
QMutableListIterator<QString> it(p);
|
QMutableListIterator<QString> it(p);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@ -89,7 +88,6 @@ QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &path
|
|||||||
QStringList *files,
|
QStringList *files,
|
||||||
QStringList *directories)
|
QStringList *directories)
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
QStringList p = paths;
|
QStringList p = paths;
|
||||||
QMutableListIterator<QString> it(p);
|
QMutableListIterator<QString> it(p);
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
@ -113,7 +111,6 @@ QStringList QPollingFileSystemWatcherEngine::removePaths(const QStringList &path
|
|||||||
|
|
||||||
void QPollingFileSystemWatcherEngine::timeout()
|
void QPollingFileSystemWatcherEngine::timeout()
|
||||||
{
|
{
|
||||||
QMutexLocker locker(&mutex);
|
|
||||||
QMutableHashIterator<QString, FileInfo> fit(files);
|
QMutableHashIterator<QString, FileInfo> fit(files);
|
||||||
while (fit.hasNext()) {
|
while (fit.hasNext()) {
|
||||||
QHash<QString, FileInfo>::iterator x = fit.next();
|
QHash<QString, FileInfo>::iterator x = fit.next();
|
||||||
|
@ -105,7 +105,6 @@ class QPollingFileSystemWatcherEngine : public QFileSystemWatcherEngine
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
mutable QMutex mutex;
|
|
||||||
QHash<QString, FileInfo> files, directories;
|
QHash<QString, FileInfo> files, directories;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
Loading…
Reference in New Issue
Block a user