ATLAS Offline Software
RCUSvc.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
13 #include "RCUSvc.h"
14 
15 
16 namespace Athena {
17 
18 
24 RCUSvc::RCUSvc (const std::string& name, ISvcLocator* svc)
25  : extends<AthService, IRCUSvc, IIncidentListener> (name, svc),
26  m_hiveWhiteBoardSvc ("EventDataSvc", name),
27  m_incidentSvc ("IncidentSvc", name)
28 {
29  declareProperty ("HiveWhiteBoardSvc", m_hiveWhiteBoardSvc);
30  declareProperty ("IncidentSvc", m_incidentSvc);
31 }
32 
33 
38 {
40  ATH_CHECK( m_hiveWhiteBoardSvc.retrieve() );
41  ATH_CHECK( m_incidentSvc.retrieve() );
42 
43  m_incidentSvc->addListener (this, IncidentType::EndEvent);
44  return StatusCode::SUCCESS;
45 }
46 
47 
51 size_t RCUSvc::getNumSlots() const
52 {
53  // In non-MT mode, `EventDataSvc' does not have an IHiveWhiteBoard interface.
54  // Fall back to one slot in that case.
55  const SmartIF<IHiveWhiteBoard> wb (m_hiveWhiteBoardSvc.get());
56  if (wb) {
57  return wb->getNumberOfStores();
58  }
59  return 1;
60 }
61 
62 
68 {
69  lock_t g (m_mutex);
70  m_objs.insert (obj);
71 }
72 
73 
81 {
82  lock_t g (m_mutex);
83  set_t::iterator it = m_objs.find (obj);
84  if (it == m_objs.end())
85  return StatusCode::FAILURE;
86  m_objs.erase (it);
87  return StatusCode::SUCCESS;
88 }
89 
90 
96 void RCUSvc::handle (const Incident& inc)
97 {
98  if (inc.type() == IncidentType::EndEvent) {
99  lock_t g (m_mutex);
100  // Be careful --- calling quiescent() below may lead to objects being
101  // removed from the set.
102  std::vector<IRCUObject*> objs (m_objs.begin(), m_objs.end());
103  for (IRCUObject* p : objs) {
104  if (m_objs.find(p) != m_objs.end()) {
105  p->quiescent (inc.context());
106  }
107  }
108  }
109 }
110 
111 
112 } // namespace Athena
113 
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
RCUSvc.h
Service to allow cleaning up RCU objects at the EndEvent.
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
Athena::RCUSvc::lock_t
std::lock_guard< std::recursive_mutex > lock_t
Definition: RCUSvc.h:102
initialize
void initialize()
Definition: run_EoverP.cxx:894
Athena::RCUSvc::add
virtual void add(IRCUObject *obj) override
Add a new RCU object to the set being managed.
Definition: RCUSvc.cxx:67
Athena::RCUSvc::RCUSvc
RCUSvc(const std::string &name, ISvcLocator *svc)
Standard Gaudi constructor.
Definition: RCUSvc.cxx:24
skel.it
it
Definition: skel.GENtoEVGEN.py:423
Athena::RCUSvc::m_mutex
std::recursive_mutex m_mutex
Mutex protecting access to m_objs.
Definition: RCUSvc.h:101
Athena::RCUSvc::handle
virtual void handle(const Incident &inc) override
Gaudi incident handler.
Definition: RCUSvc.cxx:96
Athena::RCUSvc::getNumSlots
virtual size_t getNumSlots() const override
Return the current number of event slots.
Definition: RCUSvc.cxx:51
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
python.CaloCondTools.g
g
Definition: CaloCondTools.py:15
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
Athena::RCUSvc::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Gaudi incident service.
Definition: RCUSvc.h:96
AthService
Definition: AthService.h:32
checkFileSG.objs
list objs
Definition: checkFileSG.py:93
Athena::IRCUSvc
Interface for RCU service.
Definition: IRCUSvc.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
Athena::IRCUObject
Base object class for RCU-style synchronization for Athena.
Definition: RCUObject.h:146
Athena::RCUSvc::initialize
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition: RCUSvc.cxx:37
Athena::RCUSvc::m_hiveWhiteBoardSvc
ServiceHandle< IInterface > m_hiveWhiteBoardSvc
The hive WB service. Used to get the current number of slots.
Definition: RCUSvc.h:93
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
Athena::RCUSvc::m_objs
set_t m_objs
Definition: RCUSvc.h:90
python.PyAthena.obj
obj
Definition: PyAthena.py:135
Athena::RCUSvc::remove
virtual StatusCode remove(IRCUObject *obj) override
Remove an RCU object to the set being managed.
Definition: RCUSvc.cxx:80