ATLAS Offline Software
RCUSvc.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 
3 /*
4  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
5 */
6 
15 #ifndef ATHENASERVICES_RCUSVC_H
16 #define ATHENASERVICES_RCUSVC_H
17 
18 
19 #include "AthenaKernel/IRCUSvc.h"
21 #include "GaudiKernel/ServiceHandle.h"
22 #include "GaudiKernel/IHiveWhiteBoard.h"
23 #include "GaudiKernel/IIncidentSvc.h"
24 #include "GaudiKernel/IIncidentListener.h"
25 #include <unordered_map>
26 #include <mutex>
27 
28 
29 namespace Athena {
30 
31 
39 class RCUSvc
40  : public extends<AthService, IRCUSvc, IIncidentListener>
41 {
42 public:
48  RCUSvc (const std::string& name, ISvcLocator* svc);
49 
50 
54  virtual StatusCode initialize() override;
55 
56 
60  virtual size_t getNumSlots() const override;
61 
62 
67  virtual void add (IRCUObject* obj) override;
68 
69 
76  virtual StatusCode remove (IRCUObject* obj) override;
77 
78 
84  virtual void handle (const Incident& inc) override;
85 
86 
87 private:
89  typedef std::unordered_set<IRCUObject*> set_t;
91 
94 
97 
99  // Needs to be recursive since when handle() quiesces objects,
100  // it can lead to calls to remove().
101  std::recursive_mutex m_mutex;
102  typedef std::lock_guard<std::recursive_mutex> lock_t;
103 };
104 
105 
106 } // namespace Athena
107 
108 
109 #endif // not ATHENASERVICES_RCUSVC_H
Athena::RCUSvc::lock_t
std::lock_guard< std::recursive_mutex > lock_t
Definition: RCUSvc.h:102
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
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
IRCUSvc.h
read-copy-update (RCU) style synchronization for Athena.
Athena::RCUSvc
Service to allow cleaning up RCU objects at the EndEvent.
Definition: RCUSvc.h:41
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
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
Athena::RCUSvc::set_t
std::unordered_set< IRCUObject * > set_t
Set of managed objects.
Definition: RCUSvc.h:89
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
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
AthService.h
Athena::RCUSvc::m_hiveWhiteBoardSvc
ServiceHandle< IInterface > m_hiveWhiteBoardSvc
The hive WB service. Used to get the current number of slots.
Definition: RCUSvc.h:93
Athena::RCUSvc::m_objs
set_t m_objs
Definition: RCUSvc.h:90
python.PyAthena.obj
obj
Definition: PyAthena.py:132
Athena::RCUSvc::remove
virtual StatusCode remove(IRCUObject *obj) override
Remove an RCU object to the set being managed.
Definition: RCUSvc.cxx:80
ServiceHandle< IInterface >