From 7c250b23dfaf58ed11b72e3ac45c6f971fab6436 Mon Sep 17 00:00:00 2001 From: asuraven Date: Mon, 19 Jul 2021 13:17:28 +0300 Subject: [PATCH] OSD_ThreadPool::Launcher instead OSD_Parallel::For --- src/GeomLib/GeomLib_CheckCurveOnSurface.cxx | 41 ++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx b/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx index 0e5dc24b1b..0de98e0c2d 100644 --- a/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx +++ b/src/GeomLib/GeomLib_CheckCurveOnSurface.cxx @@ -305,6 +305,23 @@ private: mutable NCollection_Array1 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 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); -- 2.39.5