Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
IncidentSvc.h
Go to the documentation of this file.
1 #ifndef IncidentSvc_IncidentSvc_H
2 #define IncidentSvc_IncidentSvc_H
3 // ============================================================================
4 // Include Files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <algorithm>
9 #include <list>
10 #include <map>
11 // ============================================================================
12 // GaudiKernel
13 // ============================================================================
15 #include "GaudiKernel/HashMap.h"
17 #include "GaudiKernel/Service.h"
18 #include "GaudiKernel/StringKey.h"
19 // ============================================================================
20 // TBB
21 // ============================================================================
22 #include "tbb/concurrent_queue.h"
23 #include "tbb/concurrent_unordered_map.h"
24 // ============================================================================
36 struct isSingleShot_t;
37 
38 class IncidentSvc : public extends<Service, IIncidentSvc> {
39 public:
40  struct Listener final {
42  long priority{0};
43  bool rethrow{false};
44  bool singleShot{false};
45 
46  Listener( IIncidentListener* il, long pri, bool thr = false, bool single = false )
47  : iListener( il ), priority( pri ), rethrow( thr ), singleShot( single ) {}
48  };
49 
50 private:
51  // Typedefs
52  // ListenerList should be a list rather than a vector because handing
53  // a fired incident may result in a call to addListener.
56 
57 public:
58  // Inherited Service overrides:
59  //
60  StatusCode initialize() override;
61  StatusCode finalize() override;
62 
63  // IIncidentSvc interfaces overwrite
64  //
65  void addListener( IIncidentListener* lis, const std::string& type = "", long priority = 0, bool rethrow = false,
66  bool singleShot = false ) override;
67 
68  void removeListener( IIncidentListener* l, const std::string& type = "" ) override;
69  void fireIncident( const Incident& incident ) override;
70  void fireIncident( std::unique_ptr<Incident> incident ) override;
71  // TODO: return by value instead...
72  void getListeners( std::vector<IIncidentListener*>& lis, const std::string& type = "" ) const override;
73 
74  // Standard Constructor.
75  IncidentSvc( const std::string& name, ISvcLocator* svc );
76  // Destructor.
77  ~IncidentSvc() override;
79 
80 private:
82  // ==========================================================================
84  void i_fireIncident( const Incident& incident, const std::string& type );
85 
87  ListenerMap m_listenerMap;
88 
92 
95 
98  mutable bool m_timerLock = false;
99  // ==========================================================================
100  // When TBB supports unique_ptrs in concurrent queue typedef should be changed
101  // typedef tbb::concurrent_queue<std::unique_ptr<Incident>> IncQueue_t;
102  typedef tbb::concurrent_queue<Incident*> IncQueue_t;
103  tbb::concurrent_unordered_map<EventContext, IncQueue_t, EventContextHash, EventContextHash> m_firedIncidents;
104 };
105 // ============================================================================
106 // The END
107 // ============================================================================
108 #endif
ChronoEntity m_timer
timer & it&#39;s lock
Definition: IncidentSvc.h:97
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
StatusCode finalize() override
Definition: IncidentSvc.cpp:71
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
bool m_timerLock
Definition: IncidentSvc.h:98
void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
Definition: IncidentSvc.cpp:91
IIncidentSvc::IncidentPack getIncidents(const EventContext *ctx) override
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
std::list< Listener > ListenerList
Definition: IncidentSvc.h:54
This class represents an entry point to all the event specific data.
Definition: EventContext.h:31
IncidentSvc(const std::string &name, ISvcLocator *svc)
Definition: IncidentSvc.cpp:49
~IncidentSvc() override
Definition: IncidentSvc.cpp:51
STL class.
The interface implemented by any class wanting to listen to Incidents.
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:94
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
void removeListener(IIncidentListener *l, const std::string &type="") override
StatusCode initialize() override
Definition: IncidentSvc.cpp:55
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:91
Listener(IIncidentListener *il, long pri, bool thr=false, bool single=false)
Definition: IncidentSvc.h:46
STL class.
IIncidentListener * iListener
Definition: IncidentSvc.h:41
tbb::concurrent_queue< Incident * > IncQueue_t
Definition: IncidentSvc.h:102
tbb::concurrent_unordered_map< EventContext, IncQueue_t, EventContextHash, EventContextHash > m_firedIncidents
Definition: IncidentSvc.h:103
dictionary l
Definition: gaudirun.py:517
void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const override
STL class.
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
Base class for all Incidents (computing events).
Definition: Incident.h:17
Common class providing an architecture-independent hash map.
Definition: HashMap.h:73
void fireIncident(const Incident &incident) override
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:87
Default implementation of the IIncidentSvc interface.
Definition: IncidentSvc.h:38
GaudiUtils::HashMap< Gaudi::StringKey, std::unique_ptr< ListenerList > > ListenerMap
Definition: IncidentSvc.h:55