Go to the documentation of this file.
45 return iNamed ? iNamed->name() : s_unknown;
50 #define ON_DEBUG if ( msgLevel( MSG::DEBUG ) )
51 #define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) )
53 #define DEBMSG ON_DEBUG debug()
54 #define VERMSG ON_VERBOSE verbose()
70 std::for_each( fi.second.unsafe_begin(), fi.second.unsafe_end(), [](
auto i ) { delete i; } );
98 auto& llist = *itMap->second;
103 [&](
const Listener& j ) {
return j.priority >= prio; } );
105 DEBMSG <<
"Adding [" <<
type <<
"] listener '" << getListenerName( lis ) <<
"' with priority " << prio <<
endmsg;
111 auto match = [&]( ListenerList::const_reference j ) {
return !item || item == j.iListener; };
113 auto&
c = *( i->second );
114 if ( !scheduleRemoval ) {
117 debug() <<
"Removing [" << i->first <<
"] listener '" << getListenerName( j.iListener ) <<
"'" <<
endmsg;
122 if ( match( i ) ) i.singleShot =
true;
132 if (
type.empty() ) {
143 constexpr
struct isSingleShot_t {
144 bool operator()(
const IncidentSvc::Listener&
l )
const {
return l.singleShot; }
157 if ( incident.
type() == IncidentType::FailInputFile || incident.
type() == IncidentType::CorruptedInputFile ) {
175 curIncTyp =
"UNKNOWN";
178 bool firedSingleShot =
false;
180 auto& listeners = *ilisteners->second;
182 for (
auto& listener : listeners ) {
184 VERMSG <<
"Calling '" << getListenerName( listener.iListener ) <<
"' for incident [" << incident.
type() <<
"]"
189 listener.iListener->handle( incident );
191 error() <<
"Exception with tag=" << exc.
tag()
193 " handling incident "
194 << curIncTyp <<
" in listener " << getListenerName( listener.iListener ) <<
endmsg;
196 if ( listener.rethrow ) {
throw exc; }
198 error() <<
"Standard std::exception is caught"
199 " handling incident "
200 << curIncTyp <<
" in listener " << getListenerName( listener.iListener ) <<
endmsg;
202 if ( listener.rethrow ) {
throw exc; }
204 error() <<
"UNKNOWN Exception is caught"
205 " handling incident "
206 << curIncTyp <<
" in listener " << getListenerName( listener.iListener ) <<
endmsg;
207 if ( listener.rethrow ) {
throw; }
210 firedSingleShot |= listener.singleShot;
212 if ( firedSingleShot ) {
229 if ( incident.
type() !=
"ALL" ) {
237 DEBMSG <<
"Async incident '" << incident->
type() <<
"' fired on context " <<
ctx <<
endmsg;
245 if ( slotItr->second !=
ctx.evt() ) {
246 slotItr->second =
ctx.evt();
249 debug() <<
"Clearing remaining obsolete incidents from slot " <<
ctx.slot() <<
":";
251 while ( incItr->second.try_pop( inc ) ) { debug() <<
" " << inc->
type() <<
"(" << inc->
context() <<
")"; }
254 incItr->second.
clear();
256 incItr->second.push( incident.
release() );
269 l.reserve( i->second->size() );
271 [](
const Listener& j ) { return j.iListener; } );
285 while ( incs->second.try_pop( inc ) ) {
iterator find(const key_type &key)
T back_inserter(T... args)
void i_fireIncident(const Incident &incident, const std::string &type)
Internal function to allow incidents listening to all events.
tbb::concurrent_unordered_map< EventContext::ContextID_t, IncQueue_t > m_firedIncidents
MSG::Level msgLevel() const
get the cached level (originally extracted from the embedded MsgStream)
StatusCode finalize() override
ChronoEntity m_timer
timer & it's lock
Default implementation of the IIncidentSvc interface.
EventContext context() const
Access to the EventContext of the source of the incident.
StatusCode setAppReturnCode(SmartIF< IProperty > &appmgr, int value, bool force=false)
Set the application return code.
void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false) override
std::string outputUserTime() const
print the chrono ;
constexpr int CorruptedInput
ListenerMap::iterator removeListenerFromList(ListenerMap::iterator, IIncidentListener *item, bool scheduleRemoval)
void clear(STATE_TYPE _i=std::ios_base::failbit)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
virtual const std::string & tag() const
name tag for the exception, or exception type
tbb::concurrent_unordered_map< EventContext::ContextID_t, EventContext::ContextEvt_t > m_slotEvent
Event ID for each slot.
iterator erase(const_iterator pos)
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
SmartIF< IFace > as() const
return a new SmartIF instance to another interface
void fireIncident(const Incident &incident) override
T emplace_back(T... args)
#define DECLARE_COMPONENT(type)
std::recursive_mutex m_listenerMapMutex
Mutex to synchronize access to m_listenerMap.
map_type::iterator iterator
std::pair< iterator, bool > insert(ValueType &&val)
void removeListener(IIncidentListener *l, const std::string &type="") override
const std::string & type() const
Access to the incident type.
IncidentSvc(const std::string &name, ISvcLocator *svc)
T partition_point(T... args)
const std::string * m_currentIncidentType
Incident being fired.
IIncidentSvc::IncidentPack getIncidents(const EventContext *ctx) override
void getListeners(std::vector< IIncidentListener * > &lis, const std::string &type="") const override
tbb::concurrent_queue< Incident * > IncQueue_t
ListenerMap m_listenerMap
List of auditor names.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
StatusCode finalize() override