The Gaudi Framework  v33r1 (b1225454)
AlgResourcePool.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIHIVE_ALGRESOURCEPOOL_H
12 #define GAUDIHIVE_ALGRESOURCEPOOL_H
13 
16 #include "GaudiKernel/IAlgorithm.h"
17 #include "GaudiKernel/Service.h"
18 #include <Gaudi/Algorithm.h>
19 
20 #include <atomic>
21 #include <bitset>
22 #include <list>
23 #include <mutex>
24 #include <string>
25 #include <vector>
26 
27 // External libs
28 #include "boost/dynamic_bitset.hpp"
29 #include "tbb/concurrent_queue.h"
30 
39 class AlgResourcePool : public extends<Service, IAlgResourcePool> {
40 public:
41  // Standard constructor
42  using extends::extends;
43  // Standard destructor
44  ~AlgResourcePool() override;
45 
46  StatusCode start() override;
47  StatusCode initialize() override;
49  StatusCode acquireAlgorithm( const std::string& name, IAlgorithm*& algo, bool blocking = false ) override;
51  StatusCode releaseAlgorithm( const std::string& name, IAlgorithm*& algo ) override;
53  StatusCode acquireResource( const std::string& name ) override;
55  StatusCode releaseResource( const std::string& name ) override;
56 
59 
60  StatusCode stop() override;
61 
62 private:
63  typedef tbb::concurrent_bounded_queue<IAlgorithm*> concurrentQueueIAlgPtr;
65  typedef boost::dynamic_bitset<> state_type;
66 
68 
75 
78 
80  StatusCode flattenSequencer( Gaudi::Algorithm* sequencer, ListAlg& alglist, unsigned int recursionDepth = 0 );
81 
82  Gaudi::Property<bool> m_lazyCreation{this, "CreateLazily", false, ""};
84  this, "TopAlg", {}, "names of the algorithms to be passed to the algorithm manager"};
85  Gaudi::Property<bool> m_overrideUnClonable{this, "OverrideUnClonable", false,
86  "override the Un-Clonability of Algorithms. Use with caution!"};
87 
90 
93 
96 
99 
102 };
103 
104 #endif // GAUDIHIVE_ALGRESOURCEPOOL_H
ListAlg m_flatUniqueAlgList
The flat list of algorithms w/o clones.
Implementation of property with value of concrete type.
Definition: Property.h:370
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
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
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:61
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:38
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:20
Base class from which all concrete algorithm classes should be derived.
Definition: Algorithm.h:89
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