History

Make script cache thread safe

Brad Davis committed 10 years ago

Commit ee017cf1 parent f97e61e2 files · +42 −12Browse files

Showing the changes to libraries/script-engine/src/ScriptCache.h (1 of 2 files). Show all

Unified · Split

libraries/script-engine/src/ScriptCache.h+5−0
@@ -12,6 +12,7 @@ · 11 unmodified lines
1212 #ifndef hifi_ScriptCache_h
1313 #define hifi_ScriptCache_h
1414
15+#include <mutex>
1516 #include <ResourceCache.h>
1617
1718 class ScriptUser {
@@ -27,6 +28,9 @@ class ScriptCache : public QObject, public Dependency { · 9 unmodified lines
2728 Q_OBJECT
2829 SINGLETON_DEPENDENCY
2930
31+ using Mutex = std::mutex;
32+ using Lock = std::unique_lock<Mutex>;
33+
3034 public:
3135 void clearCache();
3236 void getScriptContents(const QString& scriptOrURL, contentAvailableCallback contentAvailable, bool forceDownload = false);
@@ -46,6 +50,7 @@ private slots: · 13 unmodified lines
4650 private:
4751 ScriptCache(QObject* parent = NULL);
4852
53+ Mutex _containerLock;
4954 QMultiMap<QUrl, contentAvailableCallback> _contentCallbacks;
5055
5156 QHash<QUrl, QString> _scriptCache;