]> SALOME platform Git repositories - modules/yacs.git/blob - src/runtime/SalomeHPContainer.hxx
Salome HOME
SALOMEHPContainer getNumberOfFreePlace and allocateFor
[modules/yacs.git] / src / runtime / SalomeHPContainer.hxx
1 // Copyright (C) 2006-2016  CEA/DEN, EDF R&D
2 //
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Lesser General Public
5 // License as published by the Free Software Foundation; either
6 // version 2.1 of the License, or (at your option) any later version.
7 //
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 // Lesser General Public License for more details.
12 //
13 // You should have received a copy of the GNU Lesser General Public
14 // License along with this library; if not, write to the Free Software
15 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 #ifndef __SALOMEHPCONTAINER_HXX__
21 #define __SALOMEHPCONTAINER_HXX__
22
23 #include "YACSRuntimeSALOMEExport.hxx"
24 #include "HomogeneousPoolContainer.hxx"
25 #include "SalomeContainerHelper.hxx"
26 #include "SalomeContainerTools.hxx"
27 #include "SalomeHPContainerTools.hxx"
28 #include "Mutex.hxx"
29 #include <string>
30 #include <vector>
31 #include <map>
32 #include <SALOMEconfig.h>
33 #include CORBA_CLIENT_HEADER(SALOME_Component)
34 #include CORBA_CLIENT_HEADER(SALOME_ContainerManager)
35
36 namespace YACS
37 {
38   namespace ENGINE
39   {
40     class Task;
41     class SalomeComponent;
42
43     class YACSRUNTIMESALOME_EXPORT SalomeHPContainer : public HomogeneousPoolContainer
44     {
45     public:
46       SalomeHPContainer();
47       SalomeHPContainer(const SalomeHPContainer& other);
48       //HP specific part
49       void assignPG(const PlayGround *pg) override;
50       void setSizeOfPool(int sz);
51       int getSizeOfPool() const;
52       std::size_t getNumberOfFreePlace() const;
53       void allocateFor(const std::vector<const Task *>& nodes);
54       void release(const Task *node);
55       //! For thread safety for concurrent load operation on same Container.
56       void lock();
57       //! For thread safety for concurrent load operation on same Container.
58       void unLock();
59       //
60       std::string getKind() const;
61       std::string getDiscreminantStrOfThis(const Task *askingNode) const;
62       bool isAlreadyStarted(const Task *askingNode) const;
63       void start(const Task *askingNode) throw(Exception);
64       void shutdown(int level);
65       std::string getPlacementId(const Task *askingNode) const;
66       std::string getFullPlacementId(const Task *askingNode) const;
67       Container *clone() const;
68       Container *cloneAlways() const;
69       void setProperty(const std::string& name,const std::string& value);
70       std::string getProperty(const std::string& name) const;
71       void clearProperties();
72       void addComponentName(const std::string& name);
73       std::map<std::string,std::string> getProperties() const;
74       std::map<std::string,std::string> getResourceProperties(const std::string& name) const;
75       void checkCapabilityToDealWith(const ComponentInstance *inst) const throw(YACS::Exception);
76       std::vector<std::string> getKernelContainerNames() const;
77       int getNumberOfCoresPerWorker() const;
78       //
79 #ifndef SWIG
80       std::size_t locateTask(const Task *askingNode) const { return _launchModeType.locateTask(askingNode); }
81       const SalomeContainerTools &getContainerInfo() const { return _sct; }
82       std::vector<std::string> getComponentNames() const { return _componentNames; }
83       int getShutdownLev() const { return _shutdownLevel; }
84       SalomeContainerMonoHelper *getHelperOfTask(const Task *node) { return _launchModeType.getHelperOfTask(node); }
85       const SalomeContainerMonoHelper *getHelperOfTask(const Task *node) const { return _launchModeType.getHelperOfTask(node); }
86       //
87       YACS::BASES::Mutex& getLocker() { return _mutex; }
88 #endif
89     public:
90       static const char KIND[];
91     protected:
92 #ifndef SWIG
93       ~SalomeHPContainer();
94 #endif
95     protected:
96       int _shutdownLevel;
97       SalomeContainerTools _sct;
98       YACS::BASES::Mutex _mutex;
99       std::vector<std::string> _componentNames;
100       //
101       SalomeHPContainerVectOfHelper _launchModeType;
102       std::string _initScript;
103     };
104   }
105 }
106
107 #endif