Version: 8.3.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 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)
 

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 39 of file SalomeHPContainerTools.hxx.

Member Function Documentation

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

Definition at line 47 of file SalomeHPContainerTools.cxx.

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

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

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 }
const SalomeContainerMonoHelper* YACS::ENGINE::SalomeHPContainerVectOfHelper::at ( std::size_t  pos) const
inline

Definition at line 48 of file SalomeHPContainerTools.hxx.

References _launchModeType, and checkPosInVec().

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

48 { checkPosInVec(pos); return _launchModeType[pos]; }
SalomeContainerMonoHelper* YACS::ENGINE::SalomeHPContainerVectOfHelper::at ( std::size_t  pos)
inline

Definition at line 49 of file SalomeHPContainerTools.hxx.

References _launchModeType, and checkPosInVec().

49 { checkPosInVec(pos); return _launchModeType[pos]; }
void SalomeHPContainerVectOfHelper::checkNoCurrentWork ( ) const
private

Definition at line 106 of file SalomeHPContainerTools.cxx.

References _currentlyWorking, and _launchModeType.

Referenced by resize().

107 {
108  for(std::map<const Task *,std::size_t >::const_iterator it=_currentlyWorking.begin();it!=_currentlyWorking.end();it++)
109  if((*it).first)
110  throw Exception("Something wrong a node is still declared to be using the ressource !");
111  for(std::vector< YACS::BASES::AutoRefCnt<SalomeContainerMonoHelper> >::const_iterator it=_launchModeType.begin();it!=_launchModeType.end();it++)
112  if((*it)->isAlreadyStarted(0))
113  throw Exception("Some of the containers have be started ! Please shutdown them before !");
114 }
void SalomeHPContainerVectOfHelper::checkPosInVec ( std::size_t  pos) const
private

Definition at line 116 of file SalomeHPContainerTools.cxx.

References _launchModeType.

Referenced by at(), and locateTask().

117 {
118  if(pos<0 || pos>=_launchModeType.size())
119  throw Exception("The task has been found, but its id is not in the correct range ! resize of of container size during run ?");
120 }
const SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTask ( const Task node) const
SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTask ( const Task node)

Definition at line 101 of file SalomeHPContainerTools.cxx.

References _launchModeType, and locateTask().

102 {
103  return _launchModeType[locateTask(node)];
104 }
const SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe ( const SalomeHPContainer cont,
const Task node 
) const

Definition at line 84 of file SalomeHPContainerTools.cxx.

References _launchModeType, and locateTask().

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

85 {
86  YACS::BASES::AutoLocker<Container> alck(const_cast<SalomeHPContainer *>(cont));
87  return _launchModeType[locateTask(node)];
88 }
SalomeContainerMonoHelper * SalomeHPContainerVectOfHelper::getHelperOfTaskThreadSafe ( SalomeHPContainer cont,
const Task node 
)

Definition at line 95 of file SalomeHPContainerTools.cxx.

References _launchModeType, and locateTask().

96 {
98  return _launchModeType[locateTask(node)];
99 }
std::size_t SalomeHPContainerVectOfHelper::getNumberOfFreePlace ( ) const

Definition at line 42 of file SalomeHPContainerTools.cxx.

References _whichOccupied.

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

43 {
44  return std::count(_whichOccupied.begin(),_whichOccupied.end(),false);
45 }
std::size_t SalomeHPContainerVectOfHelper::locateTask ( const Task node) const

Definition at line 74 of file SalomeHPContainerTools.cxx.

References _currentlyWorking, checkPosInVec(), and PMMLBasicsTestLauncher::ret.

Referenced by getHelperOfTask(), and getHelperOfTaskThreadSafe().

75 {
76  std::map< const Task *,std::size_t >::const_iterator it(_currentlyWorking.find(node));
77  if(it==_currentlyWorking.end())
78  throw Exception("current Node to be located is not marked as launched !");
79  std::size_t ret((*it).second);
81  return ret;
82 }
void SalomeHPContainerVectOfHelper::release ( const Task node)

Definition at line 63 of file SalomeHPContainerTools.cxx.

References _currentlyWorking, and _whichOccupied.

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

64 {
65  if(!node)
66  return ;
67  std::map< const Task *,std::size_t >::iterator it(_currentlyWorking.find(node));
68  if(it==_currentlyWorking.end())
69  throw Exception("Request to release a resource not declared as working !");
70  _whichOccupied[(*it).second]=false;
71  _currentlyWorking.erase(it);
72 }
void SalomeHPContainerVectOfHelper::resize ( std::size_t  sz)

Definition at line 29 of file SalomeHPContainerTools.cxx.

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

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

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 }
std::size_t YACS::ENGINE::SalomeHPContainerVectOfHelper::size ( ) const
inline

Member Data Documentation

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

Definition at line 58 of file SalomeHPContainerTools.hxx.

Referenced by allocateFor(), getNumberOfFreePlace(), release(), and resize().


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