The Gaudi Framework  v29r0 (ff2e7097)
AlgResourcePool.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_ALGRESOURCEPOOL_H
2 #define GAUDIHIVE_ALGRESOURCEPOOL_H
3 
8 #include "GaudiKernel/Service.h"
9 // TODO: include here is only a workaround
10 #include "ControlFlowGraph.h"
11 
12 #include <atomic>
13 #include <bitset>
14 #include <list>
15 #include <mutex>
16 #include <string>
17 #include <vector>
18 
19 // External libs
20 #include "boost/dynamic_bitset.hpp"
21 #include "tbb/concurrent_queue.h"
22 
31 class AlgResourcePool : public extends<Service, IAlgResourcePool>
32 {
33 public:
34  // Standard constructor
35  using extends::extends;
36  // Standard destructor
37  ~AlgResourcePool() override;
38 
39  StatusCode start() override;
40  StatusCode initialize() override;
42  StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
44  StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
46  StatusCode acquireResource( const std::string& name ) override;
48  StatusCode releaseResource( const std::string& name ) override;
49 
52 
53  StatusCode beginRun() override;
54  StatusCode endRun() override;
55 
56  StatusCode stop() override;
57 
59 
60 private:
61  typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
63  typedef boost::dynamic_bitset<> state_type;
64 
66 
67  state_type m_available_resources{0};
73 
76 
78  StatusCode flattenSequencer( Algorithm* sequencer, ListAlg& alglist, const std::string& parentName,
79  unsigned int recursionDepth = 0 );
80 
81  Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
83  this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
84  Gaudi::Property<bool> m_overrideUnClonable{this, "OverrideUnClonable", false,
85  "override the Un-Clonability of Algorithms. Use with caution!"};
86 
88  ListAlg m_algList;
89 
91  ListAlg m_topAlgList;
92 
95 
98 
101 
104 };
105 
106 #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:319
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
Gaudi::Property< bool > m_overrideUnClonable
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:28
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
StatusCode releaseResource(const std::string &name) override
Release a certrain resource.
Gaudi::Property< std::vector< std::string > > m_topAlgNames
std::list< IAlgorithm * > getTopAlgList() override
concurrency::recursive_CF::ControlFlowGraph * getCFGraph() const
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
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.
concurrency::recursive_CF::ControlFlowGraph * m_CFGraph
OMG yet another hack.
Gaudi::Property< bool > m_lazyCreation