ATLAS Offline Software
Loading...
Searching...
No Matches
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
11
12
13#include "RCUSvc.h"
14
15
16namespace Athena {
17
18
24RCUSvc::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{
39 ATH_CHECK( AthService::initialize() );
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
51size_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
80StatusCode RCUSvc::remove (IRCUObject* obj)
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
96void 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
#define ATH_CHECK
Evaluate an expression and check for errors.
Service to allow cleaning up RCU objects at the EndEvent.
Base object class for RCU-style synchronization for Athena.
Definition RCUObject.h:147
Interface for RCU service.
Definition IRCUSvc.h:40
RCUSvc(const std::string &name, ISvcLocator *svc)
Standard Gaudi constructor.
Definition RCUSvc.cxx:24
ServiceHandle< IInterface > m_hiveWhiteBoardSvc
The hive WB service. Used to get the current number of slots.
Definition RCUSvc.h:93
virtual size_t getNumSlots() const override
Return the current number of event slots.
Definition RCUSvc.cxx:51
virtual StatusCode initialize() override
Standard Gaudi initialize method.
Definition RCUSvc.cxx:37
std::recursive_mutex m_mutex
Mutex protecting access to m_objs.
Definition RCUSvc.h:101
virtual void add(IRCUObject *obj) override
Add a new RCU object to the set being managed.
Definition RCUSvc.cxx:67
set_t m_objs
Definition RCUSvc.h:90
virtual StatusCode remove(IRCUObject *obj) override
Remove an RCU object to the set being managed.
Definition RCUSvc.cxx:80
ServiceHandle< IIncidentSvc > m_incidentSvc
Gaudi incident service.
Definition RCUSvc.h:96
std::lock_guard< std::recursive_mutex > lock_t
Definition RCUSvc.h:102
virtual void handle(const Incident &inc) override
Gaudi incident handler.
Definition RCUSvc.cxx:96
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....