ATLAS Offline Software
Loading...
Searching...
No Matches
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
18#include "GaudiKernel/IIncidentListener.h"
19
20#include <chrono>
21#include <future>
22#include <thread>
23
24
35class TimeoutAlg : public extends<AthReentrantAlgorithm, IIncidentListener>,
37{
38public:
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
47private:
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
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
Maintain a set of objects, one per slot.
Timeout singleton.
Define macros for attributes used to control the static checker.
Class to modify timeout flag.
Definition Timeout.h:77
Maintain a set of objects, one per slot.
Algorithm to monitor event timeouts.
Definition TimeoutAlg.h:37
std::promise< void > m_stop_thread
Signal to stop watchdog thread.
Definition TimeoutAlg.h:82
void handleTimeout(EventContext::ContextID_t slot)
Handle timeout.
Gaudi::Property< bool > m_dumpState
Definition TimeoutAlg.h:64
virtual void handle(const Incident &inc) override
std::mutex m_handleMutex
Mutex for handleTimeout.
Definition TimeoutAlg.h:88
virtual StatusCode stop() override
Gaudi::Property< bool > m_abort
Definition TimeoutAlg.h:67
std::atomic< bool > m_stopped
Has watchdog thread already been stopped? (to avoid setting future twice)
Definition TimeoutAlg.h:85
Gaudi::Property< unsigned long long > m_timeoutProp
Definition TimeoutAlg.h:58
void timeoutThread()
Watchdog thread.
virtual StatusCode execute(const EventContext &ctx) const override
std::chrono::nanoseconds m_timeout
Timeout property as duration.
Definition TimeoutAlg.h:73
std::chrono::steady_clock clock_t
Definition TimeoutAlg.h:48
SG::SlotSpecificObj< clock_t::time_point > m_eventStartTime ATLAS_THREAD_SAFE
Start time of each event per slot.
Definition TimeoutAlg.h:76
Gaudi::Property< unsigned long long > m_checkInterval
Definition TimeoutAlg.h:61
virtual StatusCode initialize() override
Algorithm to monitor event timeouts.