CppTools: Apply 'static' pattern to StringTable

This also fixes a crash on loading (some?) projects introduced
in 577bf7c08a.

Change-Id: Ie35d466fa3b84b183118fe93f55393a4c59755de
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
hjk
2018-02-07 13:18:48 +01:00
parent d5cd95c702
commit 87543118d5
13 changed files with 97 additions and 105 deletions

View File

@@ -25,45 +25,24 @@
#pragma once
#include <QAtomicInt>
#include <QMutex>
#include <QObject>
#include <QRunnable>
#include <QSet>
#include <QTimer>
#include <QString>
namespace CppTools {
namespace Internal {
class StringTable: public QObject
class CppToolsPluginPrivate;
class StringTable
{
Q_OBJECT
public:
StringTable();
QString insert(const QString &string);
void scheduleGC();
static QString insert(const QString &string);
static void scheduleGC();
private:
void startGC();
void GC();
class GCRunner: public QRunnable {
StringTable &m_stringTable;
public:
GCRunner(StringTable &stringTable): m_stringTable(stringTable) {}
virtual void run() { m_stringTable.GC(); }
} m_gcRunner;
friend class GCRunner;
private:
mutable QMutex m_lock;
QAtomicInt m_stopGCRequested;
QSet<QString> m_strings;
QTimer m_gcCountDown;
friend class CppToolsPluginPrivate;
static void initialize();
static void destroy();
};
} // Internal namespace
} // CppTools namespace
} // Internal
} // CppTools