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()
91 auto& llist = *itMap->second;
96 [&](
const Listener&
j ) {
return j.priority >= prio; } );
98 DEBMSG <<
"Adding [" <<
type <<
"] listener '" << getListenerName( lis ) <<
"' with priority " << prio <<
endmsg;
104 auto match = [&]( ListenerList::const_reference
j ) {
return !item || item ==
j.iListener; };
106 auto&
c = *( i->second );
107 if ( !scheduleRemoval ) {
110 debug() <<
"Removing [" << i->first <<
"] listener '" << getListenerName(
j.iListener ) <<
"'" <<
endmsg;
115 if ( match( i ) ) i.singleShot =
true;
125 if (
type.empty() ) {
136 constexpr
struct isSingleShot_t {
137 bool operator()(
const IncidentSvc::Listener&
l )
const {
return l.singleShot; }
150 if ( incident.
type() == IncidentType::FailInputFile || incident.
type() == IncidentType::CorruptedInputFile ) {
168 curIncTyp =
"UNKNOWN";
171 bool firedSingleShot =
false;
173 auto& listeners = *ilisteners->second;
175 for (
auto& listener : listeners ) {
177 VERMSG <<
"Calling '" << getListenerName( listener.iListener ) <<
"' for incident [" << incident.
type() <<
"]"
182 listener.iListener->handle( incident );
184 error() <<
"Exception with tag=" << exc.
tag()
186 " handling incident "
187 << curIncTyp <<
" in listener " << getListenerName( listener.iListener ) <<
endmsg;
189 if ( listener.rethrow ) {
throw exc; }
191 error() <<
"Standard std::exception is caught"
192 " handling incident "
193 << curIncTyp <<
" in listener " << getListenerName( listener.iListener ) <<
endmsg;
195 if ( listener.rethrow ) {
throw exc; }
197 error() <<
"UNKNOWN Exception is caught"
198 " handling incident "
199 << curIncTyp <<
" in listener " << getListenerName( listener.iListener ) <<
endmsg;
200 if ( listener.rethrow ) {
throw; }
203 firedSingleShot |= listener.singleShot;
205 if ( firedSingleShot ) {
222 if ( incident.
type() !=
"ALL" ) {
230 DEBMSG <<
"Async incident '" << incident->
type() <<
"' fired on context " <<
ctx <<
endmsg;
238 if ( slotItr->second !=
ctx.evt() ) {
239 slotItr->second =
ctx.evt();
242 debug() <<
"Clearing remaining obsolete incidents from slot " <<
ctx.slot() <<
":";
244 while ( incItr->second.try_pop( inc ) ) { debug() <<
" " << inc->
type() <<
"(" << inc->
context() <<
")"; }
247 incItr->second.
clear();
249 incItr->second.push(
std::move( incident ) );
262 l.reserve( i->second->size() );
264 [](
const Listener&
j ) { return j.iListener; } );
278 while ( incs->second.try_pop( inc ) ) {
tbb::concurrent_queue< std::unique_ptr< Incident > > IncQueue_t
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
ListenerMap m_listenerMap
List of auditor names.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator
StatusCode finalize() override