Salome HOME
Replacing std::mutex by boost::mutex as std::mutex is not on S10
[modules/smesh.git] / src / SMESH / SMESH_Mesh.hxx
index 4a0ce0e495f7629524e967292a79fa8e0d5d823a..18da4e93f0830dd7201c943af091a4b08ece2cfd 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>
+#include <boost/thread.hpp>
+
 #ifdef WIN32
 #pragma warning(disable:4251) // Warning DLL Interface ...
 #pragma warning(disable:4290) // Warning Exception ...
@@ -384,9 +386,26 @@ 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;};
+
+  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:
 
   void exportMEDCommmon(DriverMED_W_SMESHDS_Mesh& myWriter,
@@ -434,11 +453,11 @@ protected:
   TCallUp*                    _callUp;
 
   // Mutex for multhitreading write in SMESH_Mesh
-  std::mutex _my_lock;
+  boost::mutex _my_lock;
+  int _NbThreads=0;
 
 protected:
   SMESH_Mesh();
   SMESH_Mesh(const SMESH_Mesh&) {};
 };
-
 #endif