Version: 9.15.0
YACS::ENGINE::SalomeHPContainerVectOfHelper Class Reference

#include <SalomeHPContainerTools.hxx>

Collaboration diagram for YACS::ENGINE::SalomeHPContainerVectOfHelper:

Public Member Functions

std::size_t size () const
 
void resize (std::size_t sz)
 
std::size_t getNumberOfFreePlace () const
 
void allocateFor (const std::vector< const Task * > &nodes)
 
void allocateForCrude (const std::vector< std::pair< const Task *, std::size_t >> &nodes)
 
std::size_t release (const Task *node)
 
std::size_t locateTask (const Task *node) const
 
const SalomeContainerMonoHelperat (std::size_t pos) const
 
SalomeContainerMonoHelperat (std::size_t pos)
 
const SalomeContainerMonoHelpergetHelperOfTaskThreadSafe (const SalomeHPContainer *cont, const Task *node) const
 
const SalomeContainerMonoHelpergetHelperOfTask (const Task *node) const
 
SalomeContainerMonoHelpergetHelperOfTaskThreadSafe (SalomeHPContainer *cont, const Task *node)
 
SalomeContainerMonoHelpergetHelperOfTask (const Task *node)
 
std::vector< std::string > getKernelContainerNames (const SalomeHPContainer *cont) const
 

Private Member Functions

void checkNoCurrentWork () const
 
void checkPosInVec (std::size_t pos) const
 

Private Attributes

std::vector< bool > _whichOccupied
 
std::vector< BASES::AutoRefCnt< YACS::ENGINE::SalomeContainerMonoHelper > > _launchModeType
 
std::map< const Task *, std::size_t > _currentlyWorking
 

Detailed Description

Definition at line 38 of file SalomeHPContainerTools.hxx.

Member Function Documentation

◆ allocateFor()

void SalomeHPContainerVectOfHelper::allocateFor ( const std::vector< const Task * > &  nodes)

Definition at line 47 of file SalomeHPContainerTools.cxx.

48 {
49  for(std::vector<const Task *>::const_iterator it=nodes.begin();it!=nodes.end();it++)
50  {
51  if(!(*it))
52  continue;
53  if(_currentlyWorking.find(*it)!=_currentlyWorking.end())
54  throw Exception("Searching to allocate for a ServiceNode instance already declared as allocated !");
55  std::vector<bool>::iterator it2(std::find(_whichOccupied.begin(),_whichOccupied.end(),false));
56  if(it2==_whichOccupied.end())
57  throw Exception("All ressources are already occupied ! You are expected to wait for released resources !");
58  std::size_t pos(std::distance(_whichOccupied.begin(),it2));
59  _currentlyWorking[*it]=pos; _whichOccupied[pos]=true;
60  }
61 }
std::map< const Task *, std::size_t > _currentlyWorking
def distance(node, new_node)
Definition: graph.py:275

References _currentlyWorking, _whichOccupied, and gui.graph::distance().

◆ allocateForCrude()

void SalomeHPContainerVectOfHelper::allocateForCrude ( const std::vector< std::pair< const Task *, std::size_t >> &  nodes)

Definition at line 63 of file SalomeHPContainerTools.cxx.

64 {
65  for(auto it : nodes)
66  {
67  std::size_t workerId(it.second);
68  if(workerId>=size())
69  throw Exception("SalomeHPContainerVectOfHelper::allocateForCrude : Internal error ! WorkerId is greater or equal to size of HPCont !");
70  if(_whichOccupied[workerId])
71  throw Exception("SalomeHPContainerVectOfHelper::allocateForCrude : Mismatch between Playground info and HPContainer info !");
72  }
73  for(auto it : nodes)
74  {
75  const Task *task(it.first);
76  std::size_t workerId(it.second);
77  _currentlyWorking[task]=workerId;
78  _whichOccupied[workerId]=true;
79  }
80 }

References _currentlyWorking, _whichOccupied, and size().

Referenced by YACS::ENGINE::SalomeHPContainer::allocateFor().

◆ at() [1/2]

SalomeContainerMonoHelper* YACS::ENGINE::SalomeHPContainerVectOfHelper::at ( std::size_t  pos)
inline

Definition at line 49 of file SalomeHPContainerTools.hxx.

49 { checkPosInVec(pos); return _launchModeType[pos]; }
std::vector< BASES::AutoRefCnt< YACS::ENGINE::SalomeContainerMonoHelper > > _launchModeType

References _launchModeType, and checkPosInVec().

◆ at() [2/2]

const SalomeContainerMonoHelper* YACS::ENGINE::SalomeHPContainerVectOfHelper::at ( std::size_t  pos) const
inline

Definition at line 48 of file SalomeHPContainerTools.hxx.

48 { checkPosInVec(pos); return _launchModeType[pos]; }

References _launchModeType, and checkPosInVec().

Referenced by YACS::ENGINE::SalomeHPContainer::shutdown().

◆ checkNoCurrentWork()

void SalomeHPContainerVectOfHelper::checkNoCurrentWork ( ) const
private

Definition at line 141 of file SalomeHPContainerTools.cxx.

142 {
143  for(std::map<const Task *,std::size_t >::const_iterator it=_currentlyWorking.begin();it!=_currentlyWorking.end();it++)
144  if((*it).first)
145  throw Exception("Something wrong a node is still declared to be using the ressource !");
146  for(std::vector< YACS::BASES::AutoRefCnt<SalomeContainerMonoHelper> >::const_iterator it=_launchModeType.begin();it!=_launchModeType.end();it++)
147  if((*it)->isAlreadyStarted(0))
148  throw Exception("Some of the containers have be started ! Please shutdown them before !");
149 }

References _currentlyWorking, and _launchModeType.

Referenced by resize().

◆ checkPosInVec()

void SalomeHPContainerVectOfHelper::checkPosInVec ( std::size_t  pos) const
private

Definition at line 151 of file SalomeHPContainerTools.cxx.

152 {
153  if(pos<0 || pos>=_launchModeType.size())
154  throw Exception("The task has been found, but its id is not in the correct range ! resize of of container size during run ?");
155 }

References _launchModeType.

Referenced by at(), and locateTask().

◆ getHelperOfTask() [1/2]

SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTask ( const Task node)

Definition at line 121 of file SalomeHPContainerTools.cxx.

122 {
123  return _launchModeType[locateTask(node)];
124 }
std::size_t locateTask(const Task *node) const

References _launchModeType, and locateTask().

◆ getHelperOfTask() [2/2]

const SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTask ( const Task node) const

◆ getHelperOfTaskThreadSafe() [1/2]

const SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe ( const SalomeHPContainer cont,
const Task node 
) const

◆ getHelperOfTaskThreadSafe() [2/2]

SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe ( SalomeHPContainer cont,
const Task node 
)

Definition at line 115 of file SalomeHPContainerTools.cxx.

116 {
118  return _launchModeType[locateTask(node)];
119 }

References _launchModeType, and locateTask().

◆ getKernelContainerNames()

std::vector< std::string > SalomeHPContainerVectOfHelper::getKernelContainerNames ( const SalomeHPContainer cont) const

Definition at line 126 of file SalomeHPContainerTools.cxx.

127 {
128  std::vector<std::string> ret;
129  {
130  YACS::BASES::AutoLocker<Container> alck(const_cast<SalomeHPContainer *>(cont));
131  std::size_t sz(_launchModeType.size());
132  ret.resize(sz);
133  for(std::size_t i=0;i<sz;i++)
134  {
135  ret[i]=_launchModeType[i]->getKernelContainerName();
136  }
137  }
138  return ret;
139 }

References _launchModeType, and yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::SalomeHPContainer::getKernelContainerNames().

◆ getNumberOfFreePlace()

std::size_t SalomeHPContainerVectOfHelper::getNumberOfFreePlace ( ) const

Definition at line 42 of file SalomeHPContainerTools.cxx.

43 {
44  return std::count(_whichOccupied.begin(),_whichOccupied.end(),false);
45 }

References _whichOccupied.

◆ locateTask()

std::size_t SalomeHPContainerVectOfHelper::locateTask ( const Task node) const

Definition at line 94 of file SalomeHPContainerTools.cxx.

95 {
96  std::map< const Task *,std::size_t >::const_iterator it(_currentlyWorking.find(node));
97  if(it==_currentlyWorking.end())
98  throw Exception("current Node to be located is not marked as launched !");
99  std::size_t ret((*it).second);
100  checkPosInVec(ret);
101  return ret;
102 }

References _currentlyWorking, and checkPosInVec().

Referenced by getHelperOfTask(), getHelperOfTaskThreadSafe(), and YACS::ENGINE::SalomeContainerToolsDecorator::getParameters().

◆ release()

std::size_t SalomeHPContainerVectOfHelper::release ( const Task node)

Definition at line 82 of file SalomeHPContainerTools.cxx.

83 {
84  if(!node)
85  return std::numeric_limits<std::size_t>::max();
86  std::map< const Task *,std::size_t >::iterator it(_currentlyWorking.find(node));
87  if(it==_currentlyWorking.end())
88  throw Exception("Request to release a resource not declared as working !");
89  _whichOccupied[(*it).second]=false;
90  _currentlyWorking.erase(it);
91  return (*it).second;
92 }

References _currentlyWorking, and _whichOccupied.

Referenced by YACS::ENGINE::SalomeHPContainer::release().

◆ resize()

void SalomeHPContainerVectOfHelper::resize ( std::size_t  sz)

Definition at line 29 of file SalomeHPContainerTools.cxx.

30 {
31  std::size_t oldSize(_launchModeType.size());
32  if(sz==oldSize)
33  return;
35  _whichOccupied.resize(sz); std::fill(_whichOccupied.begin(),_whichOccupied.end(),false);
36  _launchModeType.resize(sz);
37  for(std::size_t i=oldSize;i<sz;i++)
39  _currentlyWorking.clear();
40 }

References _currentlyWorking, _launchModeType, _whichOccupied, checkNoCurrentWork(), and yacsorb.CORBAEngineTest::i.

Referenced by YACS::ENGINE::SalomeHPContainer::setSizeOfPool().

◆ size()

std::size_t YACS::ENGINE::SalomeHPContainerVectOfHelper::size ( ) const
inline

Member Data Documentation

◆ _currentlyWorking

std::map<const Task *,std::size_t > YACS::ENGINE::SalomeHPContainerVectOfHelper::_currentlyWorking
private

◆ _launchModeType

std::vector< BASES::AutoRefCnt<YACS::ENGINE::SalomeContainerMonoHelper> > YACS::ENGINE::SalomeHPContainerVectOfHelper::_launchModeType
private

◆ _whichOccupied

std::vector<bool> YACS::ENGINE::SalomeHPContainerVectOfHelper::_whichOccupied
private

The documentation for this class was generated from the following files: