| The Gaudi Framework v27r1

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AlgResourcePool.h
Go to the documentation of this file.
1 #ifndef GAUDIHIVE_ALGRESOURCEPOOL_H
2 #define GAUDIHIVE_ALGRESOURCEPOOL_H
3
4 // Include files
5 #include "GaudiKernel/IAlgResourcePool.h"
6 #include "GaudiKernel/IAlgManager.h"
7 #include "GaudiKernel/Service.h"
8 #include "GaudiKernel/IAlgorithm.h"
9 #include "GaudiKernel/Algorithm.h"
10
11 // TODO: include here is only a workaround
12 #include "ExecutionFlowGraph.h"
13
14 // std includes
15 #include <string>
16 #include <list>
17 #include <vector>
18 #include <bitset>
19 #include <atomic>
20 #include <mutex>
21
22 // External libs
23 #include "boost/dynamic_bitset.hpp"
24 #include "tbb/concurrent_queue.h"
25
34 class AlgResourcePool: public extends<Service,
35 IAlgResourcePool> {
36 public:
37 // Standard constructor
38 AlgResourcePool( const std::string& name, ISvcLocator* svc );
39 // Standard destructor
40 ~AlgResourcePool();
41
42 virtual StatusCode start();
43 virtual StatusCode initialize();
45 virtual StatusCode acquireAlgorithm(const std::string& name, IAlgorithm*& algo, bool blocking = false);
47 virtual StatusCode releaseAlgorithm(const std::string& name, IAlgorithm*& algo);
49 virtual StatusCode acquireResource(const std::string& name);
51 virtual StatusCode releaseResource(const std::string& name);
52
53 virtual std::list<IAlgorithm*> getFlatAlgList();
54 virtual std::list<IAlgorithm*> getTopAlgList();
55
56 virtual StatusCode beginRun();
57 virtual StatusCode endRun();
58
59 virtual StatusCode stop();
60
61 virtual concurrency::ExecutionFlowGraph* getExecutionFlowGraph() const {return m_EFGraph;}
62
63 private:
64 typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
65 typedef std::list<SmartIF<IAlgorithm> > ListAlg;
66 typedef boost::dynamic_bitset<> state_type;
67
68 std::mutex m_resource_mutex;
69 bool m_lazyCreation;
70 state_type m_available_resources;
71 std::map<size_t,concurrentQueueIAlgPtr*> m_algqueue_map;
72 std::map<size_t,state_type> m_resource_requirements;
73 std::map<size_t,size_t> m_n_of_allowed_instances;
74 std::map<size_t,unsigned int> m_n_of_created_instances;
75 std::map<std::string,unsigned int> m_resource_indices;
76
78 StatusCode decodeTopAlgs();
79
81 StatusCode flattenSequencer(Algorithm* sequencer, ListAlg& alglist, const std::string& parentName, unsigned int recursionDepth=0);
82
84 StringArrayProperty m_topAlgNames;
85
87 ListAlg m_algList;
88
90 ListAlg m_topAlgList;
91
93 ListAlg m_flatUniqueAlgList;
94
96 std::list<IAlgorithm*> m_flatUniqueAlgPtrList;
97
99 std::list<IAlgorithm*> m_topAlgPtrList;
100
102 concurrency::ExecutionFlowGraph* m_EFGraph;
103 };
104
105 #endif // GAUDIHIVE_ALGRESOURCEPOOL_H
AlgResourcePool::m_flatUniqueAlgList
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Definition: AlgResourcePool.h:93
AlgResourcePool::AlgResourcePool
AlgResourcePool(const std::string &name, ISvcLocator *svc)
Definition: AlgResourcePool.cpp:19
AlgResourcePool::releaseResource
virtual StatusCode releaseResource(const std::string &name)
Release a certrain resource.
Definition: AlgResourcePool.cpp:162
AlgResourcePool::m_topAlgNames
StringArrayProperty m_topAlgNames
The names of the algorithms to be passed to the algorithm manager.
Definition: AlgResourcePool.h:84
Algorithm.h
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
AlgResourcePool::getTopAlgList
virtual std::list< IAlgorithm * > getTopAlgList()
Definition: AlgResourcePool.cpp:372
AlgResourcePool::m_algqueue_map
std::map< size_t, concurrentQueueIAlgPtr * > m_algqueue_map
Definition: AlgResourcePool.h:71
IAlgorithm.h
IAlgResourcePool.h
AlgResourcePool::m_resource_mutex
std::mutex m_resource_mutex
Definition: AlgResourcePool.h:68
AlgResourcePool::ListAlg
std::list< SmartIF< IAlgorithm > > ListAlg
Definition: AlgResourcePool.h:65
AlgResourcePool::initialize
virtual StatusCode initialize()
Definition: AlgResourcePool.cpp:42
AlgResourcePool
The AlgResourcePool is a concrete implementation of the IAlgResourcePool interface.
Definition: AlgResourcePool.h:34
std::map< size_t, concurrentQueueIAlgPtr * >
AlgResourcePool::m_available_resources
state_type m_available_resources
Definition: AlgResourcePool.h:70
std::mutex
std::string
STL class.
SimpleProperty< std::vector< std::string > >
Service.h
AlgResourcePool::state_type
boost::dynamic_bitset state_type
Definition: AlgResourcePool.h:66
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
AlgResourcePool::m_n_of_allowed_instances
std::map< size_t, size_t > m_n_of_allowed_instances
Definition: AlgResourcePool.h:73
AlgResourcePool::concurrentQueueIAlgPtr
tbb::concurrent_bounded_queue< IAlgorithm * > concurrentQueueIAlgPtr
Definition: AlgResourcePool.h:64
AlgResourcePool::m_flatUniqueAlgPtrList
std::list< IAlgorithm * > m_flatUniqueAlgPtrList
The flat list of algorithms w/o clones which is returned.
Definition: AlgResourcePool.h:96
AlgResourcePool::acquireResource
virtual StatusCode acquireResource(const std::string &name)
Acquire a certain resource.
Definition: AlgResourcePool.cpp:153
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AlgResourcePool::m_EFGraph
concurrency::ExecutionFlowGraph * m_EFGraph
OMG yet another hack.
Definition: AlgResourcePool.h:102
AlgResourcePool::m_lazyCreation
bool m_lazyCreation
Definition: AlgResourcePool.h:69
AlgResourcePool::m_topAlgPtrList
std::list< IAlgorithm * > m_topAlgPtrList
The top list of algorithms.
Definition: AlgResourcePool.h:99
AlgResourcePool::getExecutionFlowGraph
virtual concurrency::ExecutionFlowGraph * getExecutionFlowGraph() const
Definition: AlgResourcePool.h:61
std::list< IAlgorithm * >
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:25
AlgResourcePool::start
virtual StatusCode start()
Definition: AlgResourcePool.cpp:72
AlgResourcePool::endRun
virtual StatusCode endRun()
Definition: AlgResourcePool.cpp:401
Algorithm
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:74
AlgResourcePool::decodeTopAlgs
StatusCode decodeTopAlgs()
Decode the top alg list.
Definition: AlgResourcePool.cpp:221
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
AlgResourcePool::getFlatAlgList
virtual std::list< IAlgorithm * > getFlatAlgList()
Definition: AlgResourcePool.cpp:363
AlgResourcePool::flattenSequencer
StatusCode flattenSequencer(Algorithm *sequencer, ListAlg &alglist, const std::string &parentName, unsigned int recursionDepth=0)
Recursively flatten an algList.
Definition: AlgResourcePool.cpp:171
concurrency::ExecutionFlowGraph
Definition: ExecutionFlowGraph.h:271
AlgResourcePool::m_resource_requirements
std::map< size_t, state_type > m_resource_requirements
Definition: AlgResourcePool.h:72
IAlgManager.h
AlgResourcePool::releaseAlgorithm
virtual StatusCode releaseAlgorithm(const std::string &name, IAlgorithm *&algo)
Release a certain algorithm.
Definition: AlgResourcePool.cpp:136
AlgResourcePool::m_topAlgList
ListAlg m_topAlgList
The list of top algorithms.
Definition: AlgResourcePool.h:90
AlgResourcePool::stop
virtual StatusCode stop()
Definition: AlgResourcePool.cpp:425
AlgResourcePool::m_resource_indices
std::map< std::string, unsigned int > m_resource_indices
Definition: AlgResourcePool.h:75
AlgResourcePool::~AlgResourcePool
~AlgResourcePool()
Definition: AlgResourcePool.cpp:29
AlgResourcePool::beginRun
virtual StatusCode beginRun()
Definition: AlgResourcePool.cpp:381
AlgResourcePool::m_n_of_created_instances
std::map< size_t, unsigned int > m_n_of_created_instances
Definition: AlgResourcePool.h:74
AlgResourcePool::m_algList
ListAlg m_algList
The list of all algorithms created withing the Pool which are not top.
Definition: AlgResourcePool.h:87
ExecutionFlowGraph.h
AlgResourcePool::acquireAlgorithm
virtual StatusCode acquireAlgorithm(const std::string &name, IAlgorithm *&algo, bool blocking=false)
Acquire a certain algorithm using its name.
Definition: AlgResourcePool.cpp:90