From 9f84186c16895e7a2850d03c1074340ae02ceed1 Mon Sep 17 00:00:00 2001 From: wmayer Date: Fri, 3 Jul 2020 16:06:42 +0200 Subject: [PATCH] Surface: replace std::mutex with a boolean to avoid extra overhead --- src/Mod/Surface/App/FeatureExtend.cpp | 8 ++++---- src/Mod/Surface/App/FeatureExtend.h | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Mod/Surface/App/FeatureExtend.cpp b/src/Mod/Surface/App/FeatureExtend.cpp index 53257681de38..d99c86df0414 100644 --- a/src/Mod/Surface/App/FeatureExtend.cpp +++ b/src/Mod/Surface/App/FeatureExtend.cpp @@ -46,7 +46,7 @@ const App::PropertyFloatConstraint::Constraints ToleranceRange = {0.0,10.0,0.01} const App::PropertyFloatConstraint::Constraints ExtendRange = {-0.5,10.0,0.01}; PROPERTY_SOURCE(Surface::Extend, Part::Spline) -Extend::Extend() +Extend::Extend() : lockOnChangeMutex(false) { ADD_PROPERTY(Face,(0)); Face.setScope(App::LinkScope::Global); @@ -157,9 +157,9 @@ App::DocumentObjectExecReturn *Extend::execute(void) void Extend::onChanged(const App::Property* prop) { // using a mutex and lock to protect a recursive calling when setting the new values - if (!lockOnChangeMutex.try_lock()) return; - lockOnChangeMutex.unlock(); - std::lock_guard lock(lockOnChangeMutex); + if (lockOnChangeMutex) + return; + Base::StateLocker lock(lockOnChangeMutex); if (ExtendUSymetric.getValue()) { diff --git a/src/Mod/Surface/App/FeatureExtend.h b/src/Mod/Surface/App/FeatureExtend.h index dedee29033bf..cc8cd34954b1 100644 --- a/src/Mod/Surface/App/FeatureExtend.h +++ b/src/Mod/Surface/App/FeatureExtend.h @@ -28,8 +28,6 @@ #include #include -#include - namespace Surface { @@ -51,7 +49,6 @@ class SurfaceExport Extend : public Part::Spline App::PropertyBool ExtendVSymetric; App::PropertyIntegerConstraint SampleU; App::PropertyIntegerConstraint SampleV; - std::mutex lockOnChangeMutex; // recalculate the feature App::DocumentObjectExecReturn *execute(void) override; @@ -62,6 +59,9 @@ class SurfaceExport Extend : public Part::Spline virtual void handleChangedPropertyName(Base::XMLReader &reader, const char * TypeName, const char *PropName) override; + +private: + bool lockOnChangeMutex; }; }//Namespace Surface