]> OCCT Git - occt.git/commitdiff
0033000: JT Import - perform XT translation in multiple threads CR33000
authoratychini <atychini@opencascade.com>
Thu, 30 Jun 2022 09:32:55 +0000 (12:32 +0300)
committeratychini <atychini@opencascade.com>
Tue, 5 Jul 2022 13:19:34 +0000 (16:19 +0300)
Creating mutex for proper parallel processing.

src/ShapeProcess/ShapeProcess_Context.cxx
src/XSAlgo/XSAlgo_AlgoContainer.cxx

index a010e8382b6084fda623928bff4a13ddbf50a0cc..fb58131aaf61b52774ce6b8a509a71be27bf07be 100644 (file)
 #include <ShapeProcess_Context.hxx>
 #include <Standard_ErrorHandler.hxx>
 #include <Standard_Failure.hxx>
+#include <Standard_Mutex.hxx>
 #include <Standard_Type.hxx>
 #include <TCollection_AsciiString.hxx>
 #include <TCollection_HAsciiString.hxx>
 
 #include <sys/stat.h>
-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);
 }
 
 //=======================================================================
index 7b3c0f201d625fc4a125a9e1d961c5061ad7c8d6..44179ce44f90508d516dbf02c0f47b510d169f83 100644 (file)
@@ -64,7 +64,9 @@
 #include <XSAlgo_ToolContainer.hxx>
 #include <TopExp_Explorer.hxx>
 
-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