ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaServices
src
TimeoutAlg.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration.
3
*/
4
10
11
#ifndef ATHENASERVICES_TIMEOUTALG_H
12
#define ATHENASERVICES_TIMEOUTALG_H
13
14
#include "
AthenaBaseComps/AthReentrantAlgorithm.h
"
15
#include "
AthenaKernel/SlotSpecificObj.h
"
16
#include "
AthenaKernel/Timeout.h
"
17
#include "
CxxUtils/checker_macros.h
"
18
#include "GaudiKernel/IIncidentListener.h"
19
20
#include <chrono>
21
#include <future>
22
#include <thread>
23
24
35
class
TimeoutAlg
:
public
extends<AthReentrantAlgorithm, IIncidentListener>,
36
public
Athena::TimeoutMaster
37
{
38
public
:
40
using
base_class::base_class;
41
42
virtual
StatusCode
initialize
()
override
;
43
virtual
StatusCode
execute
(
const
EventContext& ctx)
const override
;
44
virtual
StatusCode
stop
()
override
;
45
virtual
void
handle
(
const
Incident& inc)
override
;
46
47
private
:
48
using
clock_t
= std::chrono::steady_clock;
49
51
void
timeoutThread
();
52
54
void
handleTimeout
(EventContext::ContextID_t slot);
55
58
Gaudi::Property<unsigned long long>
m_timeoutProp
{
59
this
,
"Timeout"
, 0,
"Timeout in nanoseconds (0 means disabled)"
60
};
61
Gaudi::Property<unsigned long long>
m_checkInterval
{
62
this
,
"MaxCheckInterval"
, 10*1e9,
"Maximum time (ns) between timeout checks"
63
};
64
Gaudi::Property<bool>
m_dumpState
{
65
this
,
"DumpSchedulerState"
,
false
,
"Print scheduler state on timeout"
66
};
67
Gaudi::Property<bool>
m_abort
{
68
this
,
"AbortJob"
,
false
,
"Abort job on timeout"
69
};
70
71
73
std::chrono::nanoseconds
m_timeout
;
74
76
mutable
SG::SlotSpecificObj<clock_t::time_point>
m_eventStartTime
ATLAS_THREAD_SAFE
;
77
79
mutable
std::thread m_thread
ATLAS_THREAD_SAFE
;
80
82
std::promise<void>
m_stop_thread
;
83
85
std::atomic<bool>
m_stopped
{
false
};
86
88
std::mutex
m_handleMutex
;
89
};
90
91
#endif
AthReentrantAlgorithm.h
SlotSpecificObj.h
Maintain a set of objects, one per slot.
Timeout.h
Timeout singleton.
checker_macros.h
Define macros for attributes used to control the static checker.
Athena::TimeoutMaster
Class to modify timeout flag.
Definition
Timeout.h:77
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition
AthenaKernel/AthenaKernel/SlotSpecificObj.h:84
TimeoutAlg
Algorithm to monitor event timeouts.
Definition
TimeoutAlg.h:37
TimeoutAlg::m_stop_thread
std::promise< void > m_stop_thread
Signal to stop watchdog thread.
Definition
TimeoutAlg.h:82
TimeoutAlg::handleTimeout
void handleTimeout(EventContext::ContextID_t slot)
Handle timeout.
Definition
TimeoutAlg.cxx:109
TimeoutAlg::m_dumpState
Gaudi::Property< bool > m_dumpState
Definition
TimeoutAlg.h:64
TimeoutAlg::handle
virtual void handle(const Incident &inc) override
Definition
TimeoutAlg.cxx:58
TimeoutAlg::m_handleMutex
std::mutex m_handleMutex
Mutex for handleTimeout.
Definition
TimeoutAlg.h:88
TimeoutAlg::stop
virtual StatusCode stop() override
Definition
TimeoutAlg.cxx:68
TimeoutAlg::m_abort
Gaudi::Property< bool > m_abort
Definition
TimeoutAlg.h:67
TimeoutAlg::m_stopped
std::atomic< bool > m_stopped
Has watchdog thread already been stopped? (to avoid setting future twice).
Definition
TimeoutAlg.h:85
TimeoutAlg::m_timeoutProp
Gaudi::Property< unsigned long long > m_timeoutProp
Definition
TimeoutAlg.h:58
TimeoutAlg::timeoutThread
void timeoutThread()
Watchdog thread.
Definition
TimeoutAlg.cxx:81
TimeoutAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
TimeoutAlg.cxx:39
TimeoutAlg::m_timeout
std::chrono::nanoseconds m_timeout
Timeout property as duration.
Definition
TimeoutAlg.h:73
TimeoutAlg::clock_t
std::chrono::steady_clock clock_t
Definition
TimeoutAlg.h:48
TimeoutAlg::ATLAS_THREAD_SAFE
SG::SlotSpecificObj< clock_t::time_point > m_eventStartTime ATLAS_THREAD_SAFE
Start time of each event per slot.
Definition
TimeoutAlg.h:76
TimeoutAlg::m_checkInterval
Gaudi::Property< unsigned long long > m_checkInterval
Definition
TimeoutAlg.h:61
TimeoutAlg::initialize
virtual StatusCode initialize() override
Algorithm to monitor event timeouts.
Definition
TimeoutAlg.cxx:21
Generated on
for ATLAS Offline Software by
1.17.0