The Gaudi Framework  v29r0 (ff2e7097)
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 <list>
9 #include <map>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
14 #include "GaudiKernel/HashMap.h"
16 #include "GaudiKernel/Service.h"
17 #include "GaudiKernel/StringKey.h"
18 // ============================================================================
19 // TBB
20 // ============================================================================
21 #include "tbb/concurrent_queue.h"
22 #include "tbb/concurrent_unordered_map.h"
23 // ============================================================================
35 struct isSingleShot_t;
36 
37 class IncidentSvc : public extends<Service, IIncidentSvc>
38 {
39 public:
40  struct Listener final {
42  long priority;
43  bool rethrow;
44  bool singleShot;
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  };
51 
52 private:
53  // Typedefs
54  // ListenerList should be a list rather than a vector because handing
55  // a fired incident may result in a call to addListener.
58 
59 public:
60  // Inherited Service overrides:
61  //
62  StatusCode initialize() override;
63  StatusCode finalize() override;
64 
65  // IIncidentSvc interfaces overwrite
66  //
67  void addListener( IIncidentListener* lis, const std::string& type = "", long priority = 0, bool rethrow = false,
68  bool singleShot = false ) override;
69 
70  void removeListener( IIncidentListener* l, const std::string& type = "" ) override;
71  void fireIncident( const Incident& incident ) override;
72  void fireIncident( std::unique_ptr<Incident> incident ) override;
73  // TODO: return by value instead...
74  void getListeners( std::vector<IIncidentListener*>& lis, const std::string& type = "" ) const override;
75 
76  // Standard Constructor.
77  IncidentSvc( const std::string& name, ISvcLocator* svc );
78  // Destructor.
79  ~IncidentSvc() override;
81 
82 private:
84  // ==========================================================================
86  void i_fireIncident( const Incident& incident, const std::string& type );
87 
89  ListenerMap m_listenerMap;
90 
94 
97 
100  mutable bool m_timerLock = false;
101  // ==========================================================================
102  // When TBB supports unique_ptrs in concurrent queue typedef should be changed
103  // typedef tbb::concurrent_queue<std::unique_ptr<Incident>> IncQueue_t;
104  typedef tbb::concurrent_queue<Incident*> IncQueue_t;
105  tbb::concurrent_unordered_map<EventContext, IncQueue_t, EventContextHash, EventContextHash> m_firedIncidents;
106 };
107 // ============================================================================
108 // The END
109 // ============================================================================
110 #endif
111 // ============================================================================
ChronoEntity m_timer
timer & it&#39;s lock
Definition: IncidentSvc.h:99
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:289
StatusCode finalize() override
Definition: IncidentSvc.cpp:74
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:100
void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
Definition: IncidentSvc.cpp:90
IIncidentSvc::IncidentPack getIncidents(const EventContext *ctx) override
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
std::list< Listener > ListenerList
Definition: IncidentSvc.h:56
This class represents an entry point to all the event specific data.
Definition: EventContext.h:24
IncidentSvc(const std::string &name, ISvcLocator *svc)
Definition: IncidentSvc.cpp:51
~IncidentSvc() override
Definition: IncidentSvc.cpp:53
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:96
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
void removeListener(IIncidentListener *l, const std::string &type="") override
StatusCode initialize() override
Definition: IncidentSvc.cpp:57
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:93
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:104
tbb::concurrent_unordered_map< EventContext, IncQueue_t, EventContextHash, EventContextHash > m_firedIncidents
Definition: IncidentSvc.h:105
dictionary l
Definition: gaudirun.py:440
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:74
void fireIncident(const Incident &incident) override
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:89
Default implementation of the IIncidentSvc interface.
Definition: IncidentSvc.h:37
GaudiUtils::HashMap< Gaudi::StringKey, std::unique_ptr< ListenerList > > ListenerMap
Definition: IncidentSvc.h:57