diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/planner.c | 2 | ||||
-rw-r--r-- | core/profile.c | 2 | ||||
-rw-r--r-- | core/qthelper.cpp | 15 | ||||
-rw-r--r-- | core/qthelperfromc.h | 2 |
4 files changed, 21 insertions, 0 deletions
diff --git a/core/planner.c b/core/planner.c index 1e5f5db8d..a137753b2 100644 --- a/core/planner.c +++ b/core/planner.c @@ -685,6 +685,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec int decostopcounter = 0; set_gf(diveplan->gflow, diveplan->gfhigh); + lock_planner(); set_vpmb_conservatism(diveplan->vpmb_conservatism); if (!diveplan->surface_pressure) diveplan->surface_pressure = SURFACE_PRESSURE; @@ -1082,6 +1083,7 @@ bool plan(struct diveplan *diveplan, struct dive *dive, int timestep, struct dec free(stoplevels); free(gaschanges); free(bottom_cache); + unlock_planner(); return decodive; } diff --git a/core/profile.c b/core/profile.c index 6fafb3017..697ebe1c0 100644 --- a/core/profile.c +++ b/core/profile.c @@ -990,6 +990,7 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru if (!in_planner()) deco_state->deco_time = 0; struct deco_state *cache_data_initial = NULL; + lock_planner(); /* For VPM-B outside the planner, cache the initial deco state for CVA iterations */ if (decoMode() == VPMB) { cache_deco_state(&cache_data_initial); @@ -1135,6 +1136,7 @@ void calculate_deco_information(struct dive *dive, struct divecomputer *dc, stru #if DECO_CALC_DEBUG & 1 dump_tissues(); #endif + unlock_planner(); } #endif 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(); +} diff --git a/core/qthelperfromc.h b/core/qthelperfromc.h index 44f67199e..fb308c5dd 100644 --- a/core/qthelperfromc.h +++ b/core/qthelperfromc.h @@ -26,5 +26,7 @@ enum inertgas {N2, HE}; double cache_value(int tissue, int timestep, enum inertgas gas); void cache_insert(int tissue, int timestep, enum inertgas gas, double value); void print_qt_versions(); +void lock_planner(); +void unlock_planner(); #endif // QTHELPERFROMC_H |