summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Robert C. Helling <helling@atdotde.de>2017-08-29 11:41:30 +0200
committerGravatar Robert C. Helling <helling@atdotde.de>2017-11-25 20:13:01 +0100
commita9ceecc2e3646432d6688d04b592c48f9c63ae65 (patch)
treeb568677f20ab7be870f5e0ada75fc6e5cb11fe51 /core/qthelper.cpp
parentbe6b50fce403ab6fd7d9b99167f57e4aa31d2a77 (diff)
downloadsubsurface-a9ceecc2e3646432d6688d04b592c48f9c63ae65.tar.gz
Run variations calculation in background
but there are still side effects and thus it crashes. Signed-off-by: Robert C. Helling <helling@atdotde.de>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/core/qthelper.cpp b/core/qthelper.cpp
index 53cf1f841..7f72fd9a2 100644
--- a/core/qthelper.cpp
+++ b/core/qthelper.cpp
@@ -1713,11 +1713,13 @@ char *intdup(int index)
QHash<int, double> factor_cache;
+QMutex factorCacheLock;
extern "C" double cache_value(int tissue, int timestep, enum inertgas inertgas)
{
int key = (timestep << 5) + (tissue << 1);
if (inertgas == HE)
++key;
+ QMutexLocker locker(&factorCacheLock);
return factor_cache.value(key);
}
@@ -1726,6 +1728,7 @@ extern "C" void cache_insert(int tissue, int timestep, enum inertgas inertgas, d
int key = (timestep << 5) + (tissue << 1);
if (inertgas == HE)
++key;
+ QMutexLocker locker(&factorCacheLock);
factor_cache.insert(key, value);
}
@@ -1733,3 +1736,15 @@ extern "C" void print_qt_versions()
{
printf("%s\n", QStringLiteral("built with Qt Version %1, runtime from Qt Version %2").arg(QT_VERSION_STR).arg(qVersion()).toUtf8().data());
}
+
+QMutex planLock;
+
+extern "C" void lock_planner()
+{
+ planLock.lock();
+}
+
+extern "C" void unlock_planner()
+{
+ planLock.unlock();
+}