35 return iNamed ? iNamed->name() : s_unknown;
40 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 41 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 43 #define DEBMSG ON_DEBUG debug() 44 #define VERMSG ON_VERBOSE verbose() 79 std::for_each( fi.second.unsafe_begin(), fi.second.unsafe_end(), [](
auto i ) {
delete i; } );
82 m_firedIncidents.clear();
107 auto& llist = *itMap->second;
114 DEBMSG <<
"Adding [" << type <<
"] listener '" << getListenerName( lis ) <<
"' with priority " << prio <<
endmsg;
115 llist.emplace( i, lis, prio, rethrow, singleShot );
120 auto match = [&]( ListenerList::const_reference j ) {
return !item || item == j.iListener; };
122 auto&
c = *( i->second );
123 if ( !scheduleRemoval ) {
126 debug() <<
"Removing [" << i->first <<
"] listener '" << getListenerName( j.iListener ) <<
"'" <<
endmsg;
141 if ( type.empty() ) {
152 constexpr
struct isSingleShot_t {
166 if ( incident.
type() == IncidentType::FailInputFile || incident.
type() == IncidentType::CorruptedInputFile ) {
181 bool firedSingleShot =
false;
183 auto& listeners = *ilisteners->second;
185 for (
auto& listener : listeners ) {
187 VERMSG <<
"Calling '" << getListenerName( listener.iListener ) <<
"' for incident [" << incident.
type() <<
"]" 192 listener.iListener->handle( incident );
194 error() <<
"Exception with tag=" << exc.
tag()
196 " handling incident " 199 if ( listener.rethrow ) {
throw exc; }
201 error() <<
"Standard std::exception is caught" 202 " handling incident " 205 if ( listener.rethrow ) {
throw exc; }
207 error() <<
"UNKNOWN Exception is caught" 208 " handling incident " 210 if ( listener.rethrow ) {
throw; }
213 firedSingleShot |= listener.singleShot;
215 if ( firedSingleShot ) {
232 if ( incident.
type() !=
"ALL" ) {
240 auto ctx = incident->
context();
242 res.first->second.push( incident.
release() );
255 l.
reserve( i->second->size() );
257 [](
const Listener& j ) { return j.iListener; } );
270 DEBMSG <<
"Collecting listeners fired on context " << *ctx <<
endmsg;
271 while ( incs->second.try_pop( inc ) ) {
StatusCode initialize() override
ChronoEntity m_timer
timer & it's lock
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
const std::string & type() const
Access to the incident type.
StatusCode finalize() override
StatusCode finalize() override
T partition_point(T...args)
void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
IIncidentSvc::IncidentPack getIncidents(const EventContext *ctx) override
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
This class represents an entry point to all the event specific data.
IncidentSvc(const std::string &name, ISvcLocator *svc)
constexpr int CorruptedInput
std::vector< std::unique_ptr< Incident > > incidents
#define DECLARE_COMPONENT(type)
std::pair< iterator, bool > insert(ValueType &&val)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
The interface implemented by any class wanting to listen to Incidents.
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
This class is used for returning status codes from appropriate routines.
void removeListener(IIncidentListener *l, const std::string &type="") override
iterator find(const key_type &key)
virtual const std::string & tag() const
name tag for the exception, or exception type
StatusCode initialize() override
std::vector< std::vector< IIncidentListener * > > listeners
const std::string * m_currentIncidentType
Incident being fired.
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
tbb::concurrent_queue< Incident * > IncQueue_t
tbb::concurrent_unordered_map< EventContext, IncQueue_t, EventContextHash, EventContextHash > m_firedIncidents
std::string outputUserTime() const
print the chrono ;
void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const override
map_type::iterator iterator
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
virtual Out operator()(const vector_of_const_< In > &inputs) const =0
iterator erase(const_iterator pos)
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
T back_inserter(T...args)
Base class for all Incidents (computing events).
void fireIncident(const Incident &incident) override
ListenerMap m_listenerMap
List of auditor names.
Default implementation of the IIncidentSvc interface.
The IProperty is the basic interface for all components which have properties that can be set or get...
EventContext context() const
Access to the EventContext of the source of the incident.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.