Salome HOME
Created MeshLocker to replace Lock/Unlock + replacing std::cerr by exceptions + repla...
[modules/smesh.git] / src / SMESH / SMESH_Mesh.hxx
index 46a6ddc27aa02f94913be4fb9f29a2ff26a01bb2..8c4d0b18be68707fc0f5ed2cc470537b6d981ee6 100644 (file)
 
 #include "MEDCouplingMemArray.hxx"
 
-#include "ctpl.h"
-
 #include <map>
 #include <list>
 #include <vector>
 #include <ostream>
 #include <boost/filesystem.hpp>
+#include <boost/asio/thread_pool.hpp>
 
 #ifdef WIN32
 #pragma warning(disable:4251) // Warning DLL Interface ...
@@ -385,11 +384,28 @@ class SMESH_EXPORT SMESH_Mesh
 
   std::ostream& Dump(std::ostream & save);
 
+  // Parallel computation functions
+
   void Lock() {_my_lock.lock();};
   void Unlock() {_my_lock.unlock();};
 
+  int GetNbThreads(){return _NbThreads;};
+  void SetNbThreads(int nbThreads){_NbThreads=nbThreads;};
+
+  int GetMesherNbThreads(){return _MesherNbThreads;};
+  void SetMesherNbThreads(int nbThreads){_MesherNbThreads=nbThreads;};
+
+  void InitPoolThreads(){_pool = new boost::asio::thread_pool(_NbThreads);};
+  void DeletePoolThreads(){delete _pool;};
+
+  void wait(){_pool->join(); DeletePoolThreads(); InitPoolThreads(); }
+
+  bool IsParallel(){return _NbThreads > 0;}
+
   // Temporary folder used during parallel Computation
   boost::filesystem::path tmp_folder;
+  boost::asio::thread_pool *     _pool = nullptr; //thread pool for computation
+
 
 private:
 
@@ -439,10 +455,11 @@ protected:
 
   // Mutex for multhitreading write in SMESH_Mesh
   std::mutex _my_lock;
+  int _NbThreads=0;
+  int _MesherNbThreads=0;
 
 protected:
   SMESH_Mesh();
   SMESH_Mesh(const SMESH_Mesh&) {};
 };
-
 #endif