| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
IncidentSvc Class Reference

Default implementation of the IIncidentSvc interface. More...

`#include <src/IncidentSvc/IncidentSvc.h>`

Inheritance diagram for IncidentSvc:
[legend]
Collaboration diagram for IncidentSvc:
[legend]

## Classes
struct | Listener

## Public Member Functions
StatusCode | initialize () override
StatusCode | finalize () override
void | addListener (IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
void | removeListener (IIncidentListener *l, const std::string &type="") override
void | fireIncident (const Incident &incident) override
void | fireIncident (std::unique_ptr< Incident > incident) override
void | getListeners (std::vector< IIncidentListener * > &lis, const std::string &type="") const override
| IncidentSvc (const std::string &name, ISvcLocator *svc)
| ~IncidentSvc () override
IIncidentSvc::IncidentPack | getIncidents (const EventContext *ctx) override
Public Member Functions inherited from extends< Service, IIncidentSvc >
void * | i_cast (const InterfaceID &tid) const override
| Implementation of IInterface::i_cast. More...
StatusCode | queryInterface (const InterfaceID &ti, void **pp) override
| Implementation of IInterface::queryInterface. More...
std::vector< std::string > | getInterfaceNames () const override
| Implementation of IInterface::getInterfaceNames. More...
| ~extends () override=default
| Virtual destructor. More...
Public Member Functions inherited from Service
const std::string & | name () const override
| Retrieve name of the service. More...
StatusCode | configure () override
StatusCode | initialize () override
StatusCode | start () override
StatusCode | stop () override
StatusCode | finalize () override
StatusCode | terminate () override
Gaudi::StateMachine::State | FSMState () const override
Gaudi::StateMachine::State | targetFSMState () const override
StatusCode | reinitialize () override
StatusCode | restart () override
StatusCode | sysInitialize () override
| Initialize Service. More...
StatusCode | sysStart () override
| Initialize Service. More...
StatusCode | sysStop () override
| Initialize Service. More...
StatusCode | sysFinalize () override
| Finalize Service. More...
StatusCode | sysReinitialize () override
| Re-initialize the Service. More...
StatusCode | sysRestart () override
| Re-initialize the Service. More...
| Service (std::string name, ISvcLocator *svcloc)
| Standard Constructor. More...
SmartIF< ISvcLocator > & | serviceLocator () const override
| Retrieve pointer to service locator. More...
StatusCode | setProperties ()
| Method for setting declared properties to the values specified for the job. More...
template<class T >
StatusCode | service (const std::string &name, const T *&psvc, bool createIf=true) const
| Access a service by name, creating it if it doesn't already exist. More...
template<class T >
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const
template<typename IFace = IService>
SmartIF< IFace > | service (const std::string &name, bool createIf=true) const
template<class T >
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const
| Access a service by name and type, creating it if it doesn't already exist. More...
template<class T >
StatusCode | declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
| Declare used tool. More...
SmartIF< IAuditorSvc > & | auditorSvc () const
| The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| PropertyHolder ()=default
| ~PropertyHolder () override=default
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Details::PropertyBase &prop)
| Declare a property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
| Helper to wrap a regular data member and use it as a regular property. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, TYPE &value, const std::string &doc="none") const
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
| Declare a PropertyBase instance setting name and documentation. More...
Gaudi::Details::PropertyBase * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
| Declare a remote property. More...
StatusCode | setProperty (const Gaudi::Details::PropertyBase &p) override
| set the property form another property More...
StatusCode | setProperty (const std::string &s) override
| set the property from the formatted string More...
StatusCode | setProperty (const std::string &n, const std::string &v) override
| set the property from name and the value More...
StatusCode | setProperty (const std::string &name, const TYPE &value)
| set the property form the value More...
StatusCode | getProperty (Gaudi::Details::PropertyBase *p) const override
| get the property More...
const Gaudi::Details::PropertyBase & | getProperty (const std::string &name) const override
| get the property by name More...
StatusCode | getProperty (const std::string &n, std::string &v) const override
| convert the property to the string More...
const std::vector< Gaudi::Details::PropertyBase * > & | getProperties () const override
| get all properties More...
bool | hasProperty (const std::string &name) const override
| Return true if we have a property with the given name. More...
| PropertyHolder (const PropertyHolder &)=delete
PropertyHolder & | operator= (const PropertyHolder &)=delete
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleBase &ref, const std::string &doc="none")
| Specializations for various GaudiHandles. More...
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, GaudiHandleArrayBase &ref, const std::string &doc="none")
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, DataObjectHandleBase &ref, const std::string &doc="none")
Public Member Functions inherited from CommonMessagingBase
virtual | ~CommonMessagingBase ()=default
| Virtual destructor. More...
SmartIF< IMessageSvc > & | msgSvc () const
| The standard message service. More...
MsgStream & | msgStream () const
| Return an uninitialized MsgStream. More...
MsgStream & | msgStream (const MSG::Level level) const
| Predefined configurable message stream for the efficient printouts. More...
MsgStream & | always () const
| shortcut for the method msgStream(MSG::ALWAYS) More...
MsgStream & | fatal () const
| shortcut for the method msgStream(MSG::FATAL) More...
MsgStream & | err () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | error () const
| shortcut for the method msgStream(MSG::ERROR) More...
MsgStream & | warning () const
| shortcut for the method msgStream(MSG::WARNING) More...
MsgStream & | info () const
| shortcut for the method msgStream(MSG::INFO) More...
MsgStream & | debug () const
| shortcut for the method msgStream(MSG::DEBUG) More...
MsgStream & | verbose () const
| shortcut for the method msgStream(MSG::VERBOSE) More...
MsgStream & | msg () const
| shortcut for the method msgStream(MSG::INFO) More...
MSG::Level | msgLevel () const
| get the output level from the embedded MsgStream More...
MSG::Level | outputLevel () const __attribute__((deprecated))
| Backward compatibility function for getting the output level. More...
bool | msgLevel (MSG::Level lvl) const
| get the output level from the embedded MsgStream More...
Public Member Functions inherited from extend_interfaces< Interfaces... >
| ~extend_interfaces () override=default
| Virtual destructor. More...

## Private Types
typedef std::list< Listener > | ListenerList
typedef GaudiUtils::HashMap< Gaudi::StringKey, std::unique_ptr< ListenerList > > | ListenerMap
typedef tbb::concurrent_queue< Incident * > | IncQueue_t

## Private Member Functions
ListenerMap::iterator | removeListenerFromList (ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
void | i_fireIncident (const Incident &incident, const std::string &type)
| Internal function to allow incidents listening to all events. More...

## Private Attributes
ListenerMap | m_listenerMap
| List of auditor names. More...
const std::string * | m_currentIncidentType = nullptr
| Incident being fired. More...
std::recursive_mutex | m_listenerMapMutex
| Mutex to synchronize access to m_listenerMap. More...
ChronoEntity | m_timer
| timer & it's lock More...
bool | m_timerLock = false
tbb::concurrent_unordered_map< EventContext, IncQueue_t, EventContextHash, EventContextHash > | m_firedIncidents

## Additional Inherited Members
Public Types inherited from extends< Service, IIncidentSvc >
using | base_class = extends
| Typedef to this class. More...
using | extend_interfaces_base = extend_interfaces< Interfaces... >
| Typedef to the base of this class. More...
Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > | Factory
Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using | PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
| Typedef used to refer to this class from derived classes, as in. More...
Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using | base_class = CommonMessaging
Public Types inherited from extend_interfaces< Interfaces... >
using | ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
| take union of the ext_iids of all Interfaces... More...
Protected Member Functions inherited from Service
| ~Service () override
| Standard Destructor. More...
int | outputLevel () const
| get the `Service's` output level More...
Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBase * | property (const std::string &name) const
Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void | updateMsgStreamOutputLevel (int level)
| Update the output level of the cached MsgStream. More...
Protected Attributes inherited from Service
Gaudi::StateMachine::State | m_state = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::StateMachine::State | m_targetState = Gaudi::StateMachine::OFFLINE
| Service state. More...
Gaudi::Property< int > | m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
Gaudi::Property< bool > | m_auditInit {this, "AuditServices", false, "[[deprecated]] unused"}
Gaudi::Property< bool > | m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
Gaudi::Property< bool > | m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
Gaudi::Property< bool > | m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
Gaudi::Property< bool > | m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
Gaudi::Property< bool > | m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
Gaudi::Property< bool > | m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
SmartIF< IAuditorSvc > | m_pAuditorSvc
| Auditor Service. More...

## Detailed Description

Default implementation of the IIncidentSvc interface.

This implementation is thread-safe with the following features:

- Calls to fireIncident(), addListener() and removeListener() are synchronized across threads.
- Calls to IIncidentListener::handle() are serialized, i.e. at any time there is at most one incident handler being executed across all threads.

Definition at line 37 of file IncidentSvc.h.

## Member Typedef Documentation

typedef tbb::concurrent_queue<Incident*> IncidentSvc::IncQueue_t
| private

Definition at line 104 of file IncidentSvc.h.

typedef std::list<Listener> IncidentSvc::ListenerList
| private

Definition at line 56 of file IncidentSvc.h.

typedef GaudiUtils::HashMap<Gaudi::StringKey, std::unique_ptr<ListenerList> > IncidentSvc::ListenerMap
| private

Definition at line 57 of file IncidentSvc.h.

## Constructor & Destructor Documentation

IncidentSvc::IncidentSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc
| ) |  |

Definition at line 51 of file IncidentSvc.cpp.

51 : base_class( name, svc ) {}
extends< Service, IIncidentSvc >::base_class
extends base_class
Typedef to this class.
Definition: extends.h:15

IncidentSvc::~IncidentSvc | ( |  | ) |
| override

Definition at line 53 of file IncidentSvc.cpp.

53 { std::unique_lock<std::recursive_mutex> lock( m_listenerMapMutex ); }
IncidentSvc::m_listenerMapMutex
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:96
std::lock
T lock(T...args)
std::unique_lock

## Member Function Documentation

void IncidentSvc::addListener | ( | IIncidentListener * | lis,
|  | const std::string & | type = `""`,
|  | long | priority = `0`,
|  | bool | rethrow = `false`,
|  | bool | singleShot = `false`
| ) |  |
| override

Definition at line 90 of file IncidentSvc.cpp.

92 {
93 static const std::string all{"ALL"};
94 std::unique_lock<std::recursive_mutex> lock( m_listenerMapMutex );
95
96 const std::string& ltype = ( !type.empty() ? type : all );
97
98 // find if the type already exists
99 auto itMap = m_listenerMap.find( ltype );
100 if ( itMap == m_listenerMap.end() ) {
101 // if not found, create and insert now a list of listeners
102 auto p = m_listenerMap.insert( {ltype, std::unique_ptr<ListenerList>( new ListenerList() )} );
103 if ( !p.second ) { /* OOPS */
104 }
105 itMap = p.first;
106 }
107 auto& llist = *itMap->second;
108 // add Listener ordered by priority -- higher priority first,
109 // and then add behind listeneres with the same priority
110 // -- so we skip over all items with higher or same priority
111 auto i = std::partition_point( std::begin( llist ), std::end( llist ),
112 [&]( const Listener& j ) { return j.priority >= prio; } );
113 // We insert before the current position
114 DEBMSG << "Adding [" << type << "] listener '" << getListenerName( lis ) << "' with priority " << prio << endmsg;
115 llist.emplace( i, lis, prio, rethrow, singleShot );
116 }
std::string::empty
T empty(T...args)
std::partition_point
T partition_point(T...args)
IncidentSvc::ListenerList
std::list< Listener > ListenerList
Definition: IncidentSvc.h:56
std::end
T end(T...args)
DEBMSG
#define DEBMSG
Definition: IncidentSvc.cpp:45
std::string
STL class.
GaudiUtils::Map::insert
std::pair< iterator, bool > insert(ValueType &&val)
Definition: Map.h:174
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
IncidentSvc::m_listenerMapMutex
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:96
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151
std::lock
T lock(T...args)
std::unique_lock
std::unique_ptr< ListenerList >
std::begin
T begin(T...args)
IncidentSvc::m_listenerMap
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:89
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode IncidentSvc::finalize | ( |  | ) |
| override

Definition at line 74 of file IncidentSvc.cpp.

75 {
76 DEBMSG << m_timer.outputUserTime( "Incident timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] ", System::milliSec )
77 << m_timer.outputUserTime( "Total:%2%[s]", System::Sec ) << endmsg;
78
79 // Finalize this specific service
80 StatusCode sc = Service::finalize();
81 if ( UNLIKELY( sc.isFailure() ) ) {
82 return sc;
83 }
84
85 return StatusCode::SUCCESS;
86 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
StatusCode::SUCCESS
Definition: StatusCode.h:31
IncidentSvc::m_timer
ChronoEntity m_timer
timer & it&#39;s lock
Definition: IncidentSvc.h:99
Service::finalize
StatusCode finalize() override
Definition: Service.cpp:174
System::milliSec
Definition: Timing.h:58
DEBMSG
#define DEBMSG
Definition: IncidentSvc.cpp:45
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
System::Sec
Definition: Timing.h:58
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
ChronoEntity::outputUserTime
std::string outputUserTime() const
print the chrono ;
Definition: ChronoEntity.cpp:89
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void IncidentSvc::fireIncident | ( | const Incident & | incident | ) |
| override

Definition at line 236 of file IncidentSvc.cpp.

237 {
238
239 Gaudi::Utils::LockedChrono timer( m_timer, m_timerLock );
240
241 // Call specific listeners
242 i_fireIncident( incident, incident.type() );
243 // Try listeners registered for ALL incidents
244 if ( incident.type() != "ALL" ) { // avoid double calls if somebody fires the incident "ALL"
245 i_fireIncident( incident, "ALL" );
246 }
247 }
IncidentSvc::m_timer
ChronoEntity m_timer
timer & it&#39;s lock
Definition: IncidentSvc.h:99
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
IncidentSvc::m_timerLock
bool m_timerLock
Definition: IncidentSvc.h:100
Gaudi::Utils::LockedChrono
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:52
IncidentSvc::i_fireIncident
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
Definition: IncidentSvc.cpp:162

void IncidentSvc::fireIncident | ( | std::unique_ptr< Incident > | incident | ) |
| override

Definition at line 249 of file IncidentSvc.cpp.

250 {
251
252 DEBMSG << "Async incident '" << incident->type() << "' fired on context " << incident->context() << endmsg;
253 auto ctx = incident->context();
254 auto res = m_firedIncidents.insert( std::make_pair( ctx, IncQueue_t() ) );
255 res.first->second.push( incident.release() );
256 }
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
DEBMSG
#define DEBMSG
Definition: IncidentSvc.cpp:45
std::unique_ptr::release
T release(T...args)
std::make_pair
T make_pair(T...args)
IncidentSvc::IncQueue_t
tbb::concurrent_queue< Incident * > IncQueue_t
Definition: IncidentSvc.h:104
IncidentSvc::m_firedIncidents
tbb::concurrent_unordered_map< EventContext, IncQueue_t, EventContextHash, EventContextHash > m_firedIncidents
Definition: IncidentSvc.h:105
Incident::context
EventContext context() const
Access to the EventContext of the source of the incident.
Definition: Incident.h:53
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

IIncidentSvc::IncidentPack IncidentSvc::getIncidents | ( | const EventContext * | ctx | ) |
| override

Definition at line 277 of file IncidentSvc.cpp.

278 {
279 IIncidentSvc::IncidentPack p;
280 if ( ctx ) {
281 auto incs = m_firedIncidents.find( *ctx );
282 if ( incs != m_firedIncidents.end() ) {
283 Incident* inc( 0 );
284
285 DEBMSG << "Collecting listeners fired on context " << *ctx << endmsg;
286 while ( incs->second.try_pop( inc ) ) {
287 std::vector<IIncidentListener*> ls;
288 getListeners( ls, inc->type() );
289 p.incidents.emplace_back( std::move( inc ) );
290 p.listeners.emplace_back( std::move( ls ) );
291 }
292 }
293 }
294 return p;
295 }
DEBMSG
#define DEBMSG
Definition: IncidentSvc.cpp:45
IIncidentSvc::IncidentPack::incidents
std::vector< std::unique_ptr< Incident > > incidents
Definition: IIncidentSvc.h:53
IIncidentSvc::IncidentPack::listeners
std::vector< std::vector< IIncidentListener * > > listeners
Definition: IIncidentSvc.h:54
IIncidentSvc::IncidentPack
Definition: IIncidentSvc.h:50
std::move
T move(T...args)
IncidentSvc::m_firedIncidents
tbb::concurrent_unordered_map< EventContext, IncQueue_t, EventContextHash, EventContextHash > m_firedIncidents
Definition: IncidentSvc.h:105
IncidentSvc::getListeners
void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const override
Definition: IncidentSvc.cpp:259
std::vector
STL class.
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209
std::vector::emplace_back
T emplace_back(T...args)

void IncidentSvc::getListeners | ( | std::vector< IIncidentListener * > & | lis,
|  | const std::string & | type = `""`
| ) |  | const
| override

Definition at line 259 of file IncidentSvc.cpp.

260 {
261 static const std::string ALL{"ALL"};
262 std::unique_lock<std::recursive_mutex> lock( m_listenerMapMutex );
263
264 const std::string& ltype = ( !type.empty() ? type : ALL );
265
266 l.clear();
267 auto i = m_listenerMap.find( ltype );
268 if ( i != m_listenerMap.end() ) {
269 l.reserve( i->second->size() );
270 std::transform( std::begin( *i->second ), std::end( *i->second ), std::back_inserter( l ),
271 []( const Listener& j ) { return j.iListener; } );
272 }
273 }
GaudiKernel.Constants.ALL
int ALL
Definition: Constants.py:11
std::string::empty
T empty(T...args)
std::end
T end(T...args)
std::string
STL class.
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
IncidentSvc::m_listenerMapMutex
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:96
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151
std::lock
T lock(T...args)
gaudirun.l
dictionary l
Definition: gaudirun.py:440
std::unique_lock
std::begin
T begin(T...args)
std::back_inserter
T back_inserter(T...args)
std::transform
T transform(T...args)
IncidentSvc::m_listenerMap
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:89

void IncidentSvc::i_fireIncident | ( | const Incident & | incident,
|  | const std::string & | type
| ) |  |
| private

Internal function to allow incidents listening to all events.

Definition at line 162 of file IncidentSvc.cpp.

163 {
164
165 std::unique_lock<std::recursive_mutex> lock( m_listenerMapMutex );
166
167 // Wouldn't it be better to write a small 'ReturnCode' service which
168 // looks for these 'special' incidents and does whatever needs to
169 // be done instead of making a special case here?
170
171 // Special case: FailInputFile incident must set the application return code
172 if ( incident.type() == IncidentType::FailInputFile || incident.type() == IncidentType::CorruptedInputFile ) {
173 auto appmgr = serviceLocator()->as<IProperty>();
174 Gaudi::setAppReturnCode( appmgr, incident.type() == IncidentType::FailInputFile
175 ? Gaudi::ReturnCode::FailInput
176 : Gaudi::ReturnCode::CorruptedInput )
177 .ignore();
178 }
179
180 auto ilisteners = m_listenerMap.find( listenerType );
181 if ( m_listenerMap.end() == ilisteners ) return;
182
183 // setting this pointer will avoid that a call to removeListener() during
184 // the loop triggers a segfault
185 m_currentIncidentType = &incident.type();
186
187 bool firedSingleShot = false;
188
189 auto& listeners = *ilisteners->second;
190
191 for ( auto& listener : listeners ) {
192
193 VERMSG << "Calling '" << getListenerName( listener.iListener ) << "' for incident [" << incident.type() << "]"
194 << endmsg;
195
196 // handle exceptions if they occur
197 try {
198 listener.iListener->handle( incident );
199 } catch ( const GaudiException& exc ) {
200 error() << "Exception with tag=" << exc.tag() << " is caught"
201 " handling incident "
202 << *m_currentIncidentType << endmsg;
203 error() << exc << endmsg;
204 if ( listener.rethrow ) {
205 throw exc;
206 }
207 } catch ( const std::exception& exc ) {
208 error() << "Standard std::exception is caught"
209 " handling incident "
210 << *m_currentIncidentType << endmsg;
211 error() << exc.what() << endmsg;
212 if ( listener.rethrow ) {
213 throw exc;
214 }
215 } catch ( ... ) {
216 error() << "UNKNOWN Exception is caught"
217 " handling incident "
218 << *m_currentIncidentType << endmsg;
219 if ( listener.rethrow ) {
220 throw;
221 }
222 }
223 // check wheter one of the listeners is singleShot
224 firedSingleShot |= listener.singleShot;
225 }
226 if ( firedSingleShot ) {
227 // remove all the singleshot listeners that got there shot...
228 listeners.erase( std::remove_if( std::begin( listeners ), std::end( listeners ), isSingleShot ),
229 std::end( listeners ) );
230 if ( listeners.empty() ) m_listenerMap.erase( ilisteners );
231 }
232
233 m_currentIncidentType = nullptr;
234 }
GaudiException
Define general base for Gaudi exception.
Definition: GaudiException.h:22
Incident::type
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
std::end
T end(T...args)
ISvcLocator::as
SmartIF< IFace > as()
Definition: ISvcLocator.h:109
std::remove_if
T remove_if(T...args)
Gaudi::ReturnCode::CorruptedInput
constexpr int CorruptedInput
Definition: AppReturnCode.h:30
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
IncidentSvc::m_listenerMapMutex
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:96
std::exception::what
T what(T...args)
Gaudi::ReturnCode::FailInput
constexpr int FailInput
Definition: AppReturnCode.h:25
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151
std::lock
T lock(T...args)
GaudiException::tag
virtual const std::string & tag() const
name tag for the exception, or exception type
Definition: GaudiException.h:109
IncidentSvc::m_currentIncidentType
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:93
std::exception
STL class.
Gaudi::setAppReturnCode
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
Definition: AppReturnCode.h:51
std::unique_lock
GaudiUtils::Map::erase
iterator erase(const_iterator pos)
Definition: Map.h:192
VERMSG
#define VERMSG
Definition: IncidentSvc.cpp:46
std::begin
T begin(T...args)
IncidentSvc::m_listenerMap
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:89
IProperty
The IProperty is the basic interface for all components which have properties that can be set or get...
Definition: IProperty.h:20
Service::serviceLocator
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:292
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

StatusCode IncidentSvc::initialize | ( |  | ) |
| override

Definition at line 57 of file IncidentSvc.cpp.

58 {
59 // initialize the Service Base class
60 StatusCode sc = Service::initialize();
61 if ( sc.isFailure() ) return sc;
62
63 m_currentIncidentType = nullptr;
64
65 // set my own (IncidentSvc) properties via the jobOptionService
66 sc = setProperties();
67 if ( UNLIKELY( sc.isFailure() ) ) {
68 error() << "Could not set my properties" << endmsg;
69 return sc;
70 }
71 return StatusCode::SUCCESS;
72 }
UNLIKELY
#define UNLIKELY(x)
Definition: Kernel.h:128
Service::initialize
StatusCode initialize() override
Definition: Service.cpp:64
StatusCode::SUCCESS
Definition: StatusCode.h:31
StatusCode::isFailure
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
CommonMessagingBase::error
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Definition: CommonMessaging.h:111
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:28
IncidentSvc::m_currentIncidentType
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:93
Service::setProperties
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:295
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

void IncidentSvc::removeListener | ( | IIncidentListener * | l,
|  | const std::string & | type = `""`
| ) |  |
| override

Definition at line 138 of file IncidentSvc.cpp.

139 {
140 std::unique_lock<std::recursive_mutex> lock( m_listenerMapMutex );
141
142 bool scheduleForRemoval = ( m_currentIncidentType && type == *m_currentIncidentType );
143 if ( type.empty() ) {
144 auto i = std::begin( m_listenerMap );
145 while ( i != std::end( m_listenerMap ) ) {
146 i = removeListenerFromList( i, lis, scheduleForRemoval );
147 }
148 } else {
149 auto i = m_listenerMap.find( type );
150 if ( i != m_listenerMap.end() ) removeListenerFromList( i, lis, scheduleForRemoval );
151 }
152 }
IncidentSvc::removeListenerFromList
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
Definition: IncidentSvc.cpp:118
std::end
T end(T...args)
GaudiUtils::Map::end
iterator end()
Definition: Map.h:134
IncidentSvc::m_listenerMapMutex
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
Definition: IncidentSvc.h:96
GaudiUtils::Map::find
iterator find(const key_type &key)
Definition: Map.h:151
std::lock
T lock(T...args)
IncidentSvc::m_currentIncidentType
const std::string * m_currentIncidentType
Incident being fired.
Definition: IncidentSvc.h:93
std::unique_lock
std::begin
T begin(T...args)
IncidentSvc::m_listenerMap
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:89

IncidentSvc::ListenerMap::iterator IncidentSvc::removeListenerFromList | ( | ListenerMap::iterator | i,
|  | IIncidentListener * | item,
|  | bool | scheduleRemoval
| ) |  |
| private

Definition at line 118 of file IncidentSvc.cpp.

120 {
121 auto match = [&]( ListenerList::const_reference j ) { return !item || item == j.iListener; };
122
123 auto& c = *( i->second );
124 if ( !scheduleRemoval ) {
125 ON_DEBUG std::for_each( std::begin( c ), std::end( c ), [&]( ListenerList::const_reference j ) {
126 if ( match( j ) )
127 debug() << "Removing [" << i->first << "] listener '" << getListenerName( j.iListener ) << "'" << endmsg;
128 } );
129 c.erase( std::remove_if( std::begin( c ), std::end( c ), match ), std::end( c ) );
130 } else {
131 std::for_each( std::begin( c ), std::end( c ), [&]( Listener& i ) {
132 if ( match( i ) ) i.singleShot = true; // will trigger removal as soon as it is safe
133 } );
134 }
135 return c.empty() ? m_listenerMap.erase( i ) : std::next( i );
136 }
gaudirun.c
c
Definition: gaudirun.py:407
ON_DEBUG
#define ON_DEBUG
Definition: IncidentSvc.cpp:42
std::end
T end(T...args)
std::remove_if
T remove_if(T...args)
std::next
T next(T...args)
GaudiUtils::Map::erase
iterator erase(const_iterator pos)
Definition: Map.h:192
CommonMessagingBase::debug
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
Definition: CommonMessaging.h:120
std::begin
T begin(T...args)
IncidentSvc::m_listenerMap
ListenerMap m_listenerMap
List of auditor names.
Definition: IncidentSvc.h:89
std::for_each
T for_each(T...args)
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:209

## Member Data Documentation

const std::string* IncidentSvc::m_currentIncidentType = nullptr
| private

Incident being fired.

It is used to know if we can safely remove a listener or we have to schedule its removal for later.

Definition at line 93 of file IncidentSvc.h.

tbb::concurrent_unordered_map<EventContext, IncQueue_t, EventContextHash, EventContextHash> IncidentSvc::m_firedIncidents
| private

Definition at line 105 of file IncidentSvc.h.

ListenerMap IncidentSvc::m_listenerMap
| private

List of auditor names.

Definition at line 89 of file IncidentSvc.h.

std::recursive_mutex IncidentSvc::m_listenerMapMutex
| mutable private

Mutex to synchronize access to m_listenerMap.

Definition at line 96 of file IncidentSvc.h.

ChronoEntity IncidentSvc::m_timer
| mutable private

timer & it's lock

Definition at line 99 of file IncidentSvc.h.

bool IncidentSvc::m_timerLock = false
| mutable private

Definition at line 100 of file IncidentSvc.h.

The documentation for this class was generated from the following files:

- GaudiCoreSvc/src/IncidentSvc/IncidentSvc.h
- GaudiCoreSvc/src/IncidentSvc/IncidentSvc.cpp