forked from qt-creator/qt-creator
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user