]> OCCT Git - occt-copy.git/commitdiff
OSD_ThreadPool::Launcher instead OSD_Parallel::For
authorasuraven <andrey.suravenkov@opencascade.com>
Mon, 19 Jul 2021 10:17:28 +0000 (13:17 +0300)
committerasuraven <andrey.suravenkov@opencascade.com>
Mon, 26 Jul 2021 09:39:29 +0000 (12:39 +0300)
src/GeomLib/GeomLib_CheckCurveOnSurface.cxx

index 0e5dc24b1b76a2e50b1846a0b4c107dc892e5697..0de98e0c2d9d845a7edac90135cfbf330edc6a6b 100644 (file)
@@ -305,6 +305,23 @@ private:
   mutable NCollection_Array1<Standard_Real> myArrOfParam;
 };
 
+
+class GeomLib_CheckCurveOnSurface_Wrapper
+{
+public:
+  GeomLib_CheckCurveOnSurface_Wrapper(const GeomLib_CheckCurveOnSurface_Local& theFunctor) : myFunctor(theFunctor) {}
+
+  void operator() (int theThreadIndex, int theElemIndex) const
+  {
+    (void)theThreadIndex;
+    myFunctor(theElemIndex);
+  }
+private:
+  GeomLib_CheckCurveOnSurface_Wrapper(const GeomLib_CheckCurveOnSurface_Wrapper&);
+  void operator= (const GeomLib_CheckCurveOnSurface_Wrapper&);
+  const GeomLib_CheckCurveOnSurface_Local& myFunctor;
+};
+
 //=======================================================================
 //function : GeomLib_CheckCurveOnSurface
 //purpose  : 
@@ -404,8 +421,30 @@ void GeomLib_CheckCurveOnSurface::Perform(const Handle(Adaptor3d_CurveOnSurface)
 
     GeomLib_CheckCurveOnSurface_Local aComp(myCurve,theCurveOnSurface, anIntervals, 
                                             anEpsilonRange, aNbParticles);
+    if (true/*isMultiThread*/)
+    {
+      const Handle(OSD_ThreadPool)& aThreadPool = OSD_ThreadPool::DefaultPool();
+      const int aNbThreads = isMultiThread ? Min(anIntervals.Size(), aThreadPool->NbDefaultThreadsToLaunch()) : 1;
+      NCollection_Array1<Adaptor3d_Curve> anAdaptorArray(0, aNbThreads - 1);
+      for (Standard_Integer anI = 0; anI < aNbThreads; ++anI)
+      {
+//        anAdaptorArray[anI] = myCurve.ShallowCopy();
+      }
+      OSD_ThreadPool::Launcher aLauncher(*aThreadPool, aNbThreads);
+      GeomLib_CheckCurveOnSurface_Wrapper aFunctor(aComp);
+      aLauncher.Perform(anIntervals.Lower(), anIntervals.Upper()+1, aFunctor);
+    }
+    else
+    {
+      for (Standard_Integer anI = anIntervals.Lower(); anI <= anIntervals.Upper(); ++anI)
+      {
+        aComp(anI);
+      }
+    }
+
+
 
-    OSD_Parallel::For(anIntervals.Lower(), anIntervals.Upper(), aComp, false/*!isMultiThread*/);
+//    OSD_Parallel::For(anIntervals.Lower(), anIntervals.Upper(), aComp, false/*!isMultiThread*/);
 
     aComp.OptimalValues(myMaxDistance, myMaxParameter);