Salome HOME
Cleaning before merge to master.
[modules/yacs.git] / src / engine / PlayGround.hxx
index ed3719b9a44a2ce0dfebc217b3df2bc78bfe61d6..d4cf0e7cca7324291e804101b0160caa4ef32eae 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2006-2019  CEA/DEN, EDF R&D
+// Copyright (C) 2006-2020  CEA/DEN, EDF R&D
 //
 // This library is free software; you can redistribute it and/or
 // modify it under the terms of the GNU Lesser General Public
@@ -27,6 +27,7 @@
 
 #include <vector>
 #include <string>
+#include <mutex>
 #include <map>
 
 namespace YACS
@@ -45,13 +46,16 @@ namespace YACS
       std::string name() const { return _name; }
       std::size_t getNumberOfFreePlace(int nbCoresPerCont) const;
       std::vector<std::size_t> allocateFor(std::size_t& nbOfPlacesToTake, int nbCoresPerCont) const;
+      void release(std::size_t workerId, int nbCoresPerCont) const;
+      std::size_t getNumberOfWorkers(int nbCoresPerCont) const;
+      void printSelf(std::ostream& oss) const;
     private:
       std::string _name;
       int _nbCores;
       mutable std::vector<bool> _occupied;
     };
-    
-    
+
+
     class ResourceIterator : public std::iterator<
                         std::input_iterator_tag,     // iterator_category
                         Resource,                    // value_type
@@ -93,6 +97,9 @@ namespace YACS
     public:// critical section part
       std::size_t getNumberOfFreePlace(int nbCoresPerCont) const;
       std::vector<std::size_t> allocateFor(std::size_t nbOfPlacesToTake, int nbCoresPerCont) const;
+      void release(std::size_t workerId, int nbCoresPerCont) const;
+      std::mutex& getLocker() const { return _locker; }
+      void printMe() const;
     private:
       std::vector< std::pair <const ComplexWeight *, int> > bigToTiny(const std::vector< std::pair <const ComplexWeight *, int> > &weights, std::map<int,int> &saveOrder) const;
          std::vector< std::vector<int> > backToOriginalOrder(const std::vector< std::vector<int> > &disorderVec, const std::map<int,int> &saveOrder) const;
@@ -104,6 +111,7 @@ namespace YACS
     private:
       ~PlayGround();
     private:
+      mutable std::mutex _locker;
       std::vector< Resource > _data;
     };