The Gaudi Framework  v30r3 (a5ef0a68)
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 
10 #include <atomic>
11 #include <bitset>
12 #include <list>
13 #include <mutex>
14 #include <string>
15 #include <vector>
16 
17 // External libs
18 #include "boost/dynamic_bitset.hpp"
19 #include "tbb/concurrent_queue.h"
20 
29 class AlgResourcePool : public extends<Service, IAlgResourcePool>
30 {
31 public:
32  // Standard constructor
33  using extends::extends;
34  // Standard destructor
35  ~AlgResourcePool() override;
36 
37  StatusCode start() override;
38  StatusCode initialize() override;
40  StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
42  StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
44  StatusCode acquireResource( const std::string& name ) override;
46  StatusCode releaseResource( const std::string& name ) override;
47 
50 
51  StatusCode stop() override;
52 
53 private:
54  typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
56  typedef boost::dynamic_bitset<> state_type;
57 
59 
60  state_type m_available_resources{0};
66 
69 
71  StatusCode flattenSequencer( Algorithm* sequencer, ListAlg& alglist, unsigned int recursionDepth = 0 );
72 
73  Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
75  this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
76  Gaudi::Property<bool> m_overrideUnClonable{this, "OverrideUnClonable", false,
77  "override the Un-Clonability of Algorithms. Use with caution!"};
78 
80  ListAlg m_algList;
81 
83  ListAlg m_topAlgList;
84 
87 
90 
93 };
94 
95 #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:288
Implementation of property with value of concrete type.
Definition: Property.h:381
std::map< std::string, unsigned int > m_resource_indices
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, unsigned int recursionDepth=0)
Recursively flatten an algList.
std::mutex m_resource_mutex
std::list< SmartIF< IAlgorithm > > ListAlg
StatusCode stop() 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:51
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
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 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