Skip to content

Commit

Permalink
Surface: replace std::mutex with a boolean to avoid extra overhead
Browse files Browse the repository at this point in the history
  • Loading branch information
wwmayer committed Jul 3, 2020
1 parent 74ad645 commit 9f84186
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions src/Mod/Surface/App/FeatureExtend.cpp
Expand Up @@ -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);
Expand Down Expand Up @@ -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<std::mutex> lock(lockOnChangeMutex);
if (lockOnChangeMutex)
return;
Base::StateLocker lock(lockOnChangeMutex);

if (ExtendUSymetric.getValue())
{
Expand Down
6 changes: 3 additions & 3 deletions src/Mod/Surface/App/FeatureExtend.h
Expand Up @@ -28,8 +28,6 @@
#include <App/PropertyLinks.h>
#include <Mod/Part/App/FeaturePartSpline.h>

#include <mutex>

namespace Surface
{

Expand All @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit 9f84186

Please sign in to comment.