-// 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
#include <vector>
#include <string>
+#include <mutex>
#include <map>
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
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;
private:
~PlayGround();
private:
+ mutable std::mutex _locker;
std::vector< Resource > _data;
};