Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
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 
7 #include "GaudiKernel/Service.h"
8 #include <Gaudi/Algorithm.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 public:
31  // Standard constructor
32  using extends::extends;
33  // Standard destructor
34  ~AlgResourcePool() override;
35 
36  StatusCode start() override;
37  StatusCode initialize() override;
39  StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
41  StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
43  StatusCode acquireResource( const std::string& name ) override;
45  StatusCode releaseResource( const std::string& name ) override;
46 
49 
50  StatusCode stop() override;
51 
52 private:
53  typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
55  typedef boost::dynamic_bitset<> state_type;
56 
58 
59  state_type m_available_resources{0};
65 
68 
70  StatusCode flattenSequencer( Gaudi::Algorithm* sequencer, ListAlg& alglist, unsigned int recursionDepth = 0 );
71 
72  Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
74  this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
75  Gaudi::Property<bool> m_overrideUnClonable{this, "OverrideUnClonable", false,
76  "override the Un-Clonability of Algorithms. Use with caution!"};
77 
79  ListAlg m_algList;
80 
82  ListAlg m_topAlgList;
83 
86 
89 
92 };
93 
94 #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:274
Implementation of property with value of concrete type.
Definition: Property.h:352
std::map< std::string, unsigned int > m_resource_indices
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:50
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
StatusCode decodeTopAlgs()
Decode the top alg list.
StatusCode flattenSequencer(Gaudi::Algorithm *sequencer, ListAlg &alglist, unsigned int recursionDepth=0)
Recursively flatten an algList.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:79
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