From: atychini Date: Thu, 30 Jun 2022 09:32:55 +0000 (+0300) Subject: 0033000: JT Import - perform XT translation in multiple threads X-Git-Url: http://git.dev.opencascade.org/gitweb/?a=commitdiff_plain;h=cbc7d857f54083c93819cdf3df0c7e0f12a1e5a1;p=occt.git 0033000: JT Import - perform XT translation in multiple threads Creating mutex for proper parallel processing. --- diff --git a/src/ShapeProcess/ShapeProcess_Context.cxx b/src/ShapeProcess/ShapeProcess_Context.cxx index a010e8382b..fb58131aaf 100644 --- a/src/ShapeProcess/ShapeProcess_Context.cxx +++ b/src/ShapeProcess/ShapeProcess_Context.cxx @@ -20,12 +20,15 @@ #include #include #include +#include #include #include #include #include -IMPLEMENT_STANDARD_RTTIEXT(ShapeProcess_Context,Standard_Transient) +IMPLEMENT_STANDARD_RTTIEXT(ShapeProcess_Context, Standard_Transient) + +static Standard_Mutex THE_SHAPE_PROCESS_MUTEX; //======================================================================= //function : ShapeProcess_Context @@ -73,6 +76,7 @@ Standard_Boolean ShapeProcess_Context::Init (const Standard_CString file, Handle(Resource_Manager) ShapeProcess_Context::LoadResourceManager (const Standard_CString name) { + Standard_Mutex::Sentry aLock(&THE_SHAPE_PROCESS_MUTEX); // Optimisation of loading resource file: file is load only once // and reloaded only if file date has changed static Handle(Resource_Manager) sRC; @@ -127,7 +131,7 @@ Handle(Resource_Manager) ShapeProcess_Context::LoadResourceManager (const Standa sUMtime = aUMtime; } } - return sRC; + return new Resource_Manager(*sRC); } //======================================================================= diff --git a/src/XSAlgo/XSAlgo_AlgoContainer.cxx b/src/XSAlgo/XSAlgo_AlgoContainer.cxx index 7b3c0f201d..44179ce44f 100644 --- a/src/XSAlgo/XSAlgo_AlgoContainer.cxx +++ b/src/XSAlgo/XSAlgo_AlgoContainer.cxx @@ -64,7 +64,9 @@ #include #include -IMPLEMENT_STANDARD_RTTIEXT(XSAlgo_AlgoContainer,Standard_Transient) +IMPLEMENT_STANDARD_RTTIEXT(XSAlgo_AlgoContainer, Standard_Transient) + +static Standard_Mutex THE_RESOURCE_MUTEX; //======================================================================= //function : XSAlgo_AlgoContainer @@ -167,9 +169,11 @@ TopoDS_Shape XSAlgo_AlgoContainer::ProcessShape (const TopoDS_Shape& shape, } // Define runtime tolerances and do Shape Processing - rsc->SetResource ( "Runtime.Tolerance", Prec ); - rsc->SetResource ( "Runtime.MaxTolerance", maxTol ); - + { + Standard_Mutex::Sentry aLock(&THE_RESOURCE_MUTEX); + rsc->SetResource("Runtime.Tolerance", Prec); + rsc->SetResource("Runtime.MaxTolerance", maxTol); + } if ( !ShapeProcess::Perform(context, seq, theProgress) ) return shape; // return original shape