ATLAS Offline Software
Loading...
Searching...
No Matches
AthCommonReentrantAlgorithm.cxx
Go to the documentation of this file.
1
2
3/*
4 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
5*/
6
7// AthReentrantAlgorithm.cxx
8// Implementation file for class AthReentrantAlgorithm
9// Author: C. Leggett
11
12// AthenaBaseComps includes
15#include "GaudiKernel/ICondSvc.h"
16#include "GaudiKernel/ServiceHandle.h"
17
18// Gaudi includes
19#include "Gaudi/Algorithm.h"
20#include "Gaudi/AsynchronousAlgorithm.h"
21
22// Framework includes
23#include "GaudiKernel/ThreadLocalContext.h"
24
25template <class BaseAlg>
27 ISvcLocator* pSvcLocator ) :
28 ::AthCommonDataStore<AthCommonMsg<BaseAlg>> ( name, pSvcLocator )
29{
30
31 // Set up to run AthAlgorithmDHUpdate in sysInitialize before
32 // merging depedency lists. This extends the output dependency
33 // list with any symlinks implied by inheritance relations.
34 m_updateDataHandles =
35 std::make_unique<AthenaBaseComps::AthAlgorithmDHUpdate>
37 std::move (m_updateDataHandles));
38}
39
40// Destructor
42template <class BaseAlg>
47
50template <class BaseAlg>
52{
53 // Reentrant algorithms are clonable.
54 return true;
55}
56
61 */
62template <class BaseAlg>
64{
65 return 0;
66}
67
68/**
69 * @brief Execute an algorithm.
70 *
71 * We override this in order to work around an issue with the Algorithm
72 * base class storing the event context in a member variable that can
73 * cause crashes in MT jobs.
74 */
75template <class BaseAlg>
76StatusCode AthCommonReentrantAlgorithm<BaseAlg>::sysExecute (const EventContext& ctx)
77{
78 return BaseAlg::sysExecute (ctx);
79}
80
81
85 * This list is extended to include symlinks implied by inheritance
86 * relations.
87 */
88template <class BaseAlg>
90{
91 // If we didn't find any symlinks to add, just return the collection
92 // from the base class. Otherwise, return the extended collection.
93 if (!m_extendedExtraObjects.empty()) {
95 }
96 return BaseAlg::extraOutputDeps();
97}
98
99
106template <class BaseAlg>
109
110 if (sc.isFailure()) {
111 return sc;
112 }
113
114 ServiceHandle<ICondSvc> cs("CondSvc",name());
115 for (auto h : outputHandles()) {
116 if (h->isCondition() && h->mode() == Gaudi::DataHandle::Writer) {
117 // do this inside the loop so we don't create the CondSvc until needed
118 if ( cs.retrieve().isFailure() ) {
119 ATH_MSG_WARNING("no CondSvc found: won't autoreg WriteCondHandles");
120 return StatusCode::SUCCESS;
121 }
122 if (cs->regHandle(this,*h).isFailure()) {
123 sc = StatusCode::FAILURE;
124 ATH_MSG_ERROR("unable to register WriteCondHandle " << h->fullKey()
125 << " with CondSvc");
126 }
127 }
128 }
129 return sc;
130}
131
Update output dependencies to include symlinks.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
static Double_t sc
AthCommonDataStore(const std::string &name, T... args)
virtual std::vector< Gaudi::DataHandle * > outputHandles() const override
An algorithm that can be simultaneously executed in multiple threads.
virtual bool isClonable() const override
Specify if the algorithm is clonable.
DataObjIDColl m_extendedExtraObjects
Extra output dependency collection, extended by AthAlgorithmDHUpdate to add symlinks.
virtual StatusCode sysInitialize() override
Override sysInitialize.
AthCommonReentrantAlgorithm()
Default constructor:
virtual ~AthCommonReentrantAlgorithm() override
Destructor:
virtual StatusCode sysExecute(const EventContext &ctx) override
Execute an algorithm.
virtual const DataObjIDColl & extraOutputDeps() const override
Return the list of extra output dependencies.
virtual unsigned int cardinality() const override
Cardinality (Maximum number of clones that can exist) special value 0 means that algorithm is reentra...
Header file for AthHistogramAlgorithm.