All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgResourcePool.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_ALGRESOURCEPOOL_H
2 #define GAUDIHIVE_ALGRESOURCEPOOL_H
3 
4 // Include files
9 #include "GaudiKernel/Service.h"
10 
11 // TODO: include here is only a workaround
12 #include "ExecutionFlowGraph.h"
13 
14 // std includes
15 #include <atomic>
16 #include <bitset>
17 #include <list>
18 #include <mutex>
19 #include <string>
20 #include <vector>
21 
22 // External libs
23 #include "boost/dynamic_bitset.hpp"
24 #include "tbb/concurrent_queue.h"
25 
34 class AlgResourcePool : public extends<Service, IAlgResourcePool>
35 {
36 public:
37  // Standard constructor
38  using extends::extends;
39  // Standard destructor
40  ~AlgResourcePool() override;
41 
42  StatusCode start() override;
43  StatusCode initialize() override;
45  StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
47  StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
49  StatusCode acquireResource( const std::string& name ) override;
51  StatusCode releaseResource( const std::string& name ) override;
52 
55 
56  StatusCode beginRun() override;
57  StatusCode endRun() override;
58 
59  StatusCode stop() override;
60 
62 
63 private:
64  typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
66  typedef boost::dynamic_bitset<> state_type;
67 
69 
70  state_type m_available_resources{0};
76 
79 
81  StatusCode flattenSequencer( Algorithm* sequencer, ListAlg& alglist, const std::string& parentName,
82  unsigned int recursionDepth = 0 );
83 
84  Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
86  this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
87 
89  ListAlg m_algList;
90 
92  ListAlg m_topAlgList;
93 
96 
99 
102 
105 };
106 
107 #endif // GAUDIHIVE_ALGRESOURCEPOOL_H
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:289
Implementation of property with value of concrete type.
Definition: Property.h:313
std::map< std::string, unsigned int > m_resource_indices
std::mutex m_resource_mutex
StatusCode beginRun() override
std::list< SmartIF< IAlgorithm > > ListAlg
StatusCode stop() override
StatusCode endRun() override
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
state_type m_available_resources
STL class.
boost::dynamic_bitset state_type
tbb::concurrent_bounded_queue< IAlgorithm * > concurrentQueueIAlgPtr
std::list< IAlgorithm * > m_flatUniqueAlgPtrList
The flat list of algorithms w/o clones which is returned.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
concurrency::ExecutionFlowGraph * m_EFGraph
OMG yet another hack.
std::map< size_t, state_type > m_resource_requirements
StatusCode start() override
~AlgResourcePool() override
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
std::list< IAlgorithm * > getFlatAlgList() override
virtual concurrency::ExecutionFlowGraph * getExecutionFlowGraph() const
StatusCode releaseResource(const std::string &name) override
Release a certrain resource.
Gaudi::Property< std::vector< std::string > > m_topAlgNames
std::list< IAlgorithm * > getTopAlgList() override
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:27
StatusCode acquireResource(const std::string &name) override
Acquire a certain resource.
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:78
StatusCode decodeTopAlgs()
Decode the top alg list.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, const std::string &parentName, unsigned int recursionDepth=0)
Recursively flatten an algList.
StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false) override
Acquire a certain algorithm using its name.
std::map< size_t, unsigned int > m_n_of_created_instances
StatusCode initialize() override
ListAlg m_topAlgList
The list of top algorithms.
std::map< size_t, size_t > m_n_of_allowed_instances
ListAlg m_algList
The list of all algorithms created withing the Pool which are not top.
StatusCode releaseAlgorithm(const std::string &name, IAlgorithm *&algo) override
Release a certain algorithm.
Gaudi::Property< bool > m_lazyCreation