24 const std::string &name,
25 boost::posix_time::time_duration timeout,
26 bool stackTrace =
false,
28 bool autostart =
false):
33 m_stackTrace(stackTrace){}
34 virtual ~EventWatchdog() {}
57 if (m_stackTrace && gSystem) {
59 std::cerr <<
"=== Stalled event: current stack trace ===" << std::endl;
60 gSystem->StackTrace();
63 if (m_maxCount > 0 && m_counter >= m_maxCount) {
89 "Number of seconds allowed to process a single event (0 to disable the check).");
92 "Number timeouts before aborting the execution (0 means never abort).");
95 "Whether to print the stack-trace on timeout.");
112 new EventWatchdog(
msgSvc(),
119 std::string serviceName =
"IncidentSvc";
122 error() <<
"Cannot retrieve " << serviceName <<
endmsg;
125 debug() <<
"Register to the IncidentSvc" <<
endmsg;
129 <<
" instantiated with 0 time-out: no monitoring performed" <<
endmsg;
159 return base_class::finalize();
const std::string BeginEvent
Processing of a new event has started.
Definition of the MsgStream class used to transmit messages.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
boost::posix_time::time_duration getTimeout() const
Get the current time-out value.
virtual void onStop()
User implemented function that will be called when stopping.
virtual StatusCode start()
Start the watchdog thread (before entering the event loop).
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
virtual StatusCode initialize()
Initialization of the service.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
bool m_stackTrace
Whether to print a stack-trace on timeout.
bool isFailure() const
Test for a status code of FAILURE.
#define DECLARE_COMPONENT(type)
Service that monitor the time taken by processing of single events using a separate thread...
SmartIF< IIncidentSvc > m_incidentSvc
Pointer to the incident service.
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
This class is used for returning status codes from appropriate routines.
int m_maxTimeoutCount
Number timeouts before aborting the execution (0 means never abort).
unsigned int m_eventTimeout
Number of seconds allowed to process a single event.
StalledEventMonitor(const std::string &name, ISvcLocator *svcLoc)
Constructor.
virtual const std::string & name() const
Retrieve name of the service.
virtual void handle(const Incident &)
Notify the watchdog thread for a new event.
virtual void onPing()
User implemented function that will be called when ping is called.
Simple class for asynchronous check of time-out.
Base class for all Incidents (computing events).
Templated class to add the standard messaging functionalities.
GAUDI_API long virtualMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: priority boost.
virtual ~StalledEventMonitor()
Destructor.
virtual StatusCode finalize()
Finalization of the service.
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
virtual void action()
User implemented function that will be called if the time-out is reached.
std::auto_ptr< WatchdogThread > m_watchdog
Pointer to the watchdog thread that checks for the event timeout.
virtual StatusCode stop()
Stop the watchdog thread (after the event loop).
void reset(TYPE *ptr=0)
Set the internal pointer to the passed one disposing of the old one.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
GAUDI_API long pagedMemory(MemoryUnit unit=kByte, InfoType fetch=Memory, long pid=-1)
Basic Process Information: Amount of paged memory currently occupied by the process 'pid'...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
SmartIF< ISvcLocator > & serviceLocator() const
Retrieve pointer to service locator.