ATLAS Offline Software
Loading...
Searching...
No Matches
Timeout.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef ATHENAKERNEL_TIMEOUT_H
6#define ATHENAKERNEL_TIMEOUT_H 1
7
15
16
18#include "GaudiKernel/ThreadLocalContext.h"
19#include <atomic>
20
21
22namespace Athena {
23
24 // Forward declarations
25 class TimeoutMaster;
26
35 class Timeout {
37 friend class TimeoutMaster;
38
39 public:
41 static Timeout& instance();
42 static Timeout& instance(const EventContext& ctx);
43
45 bool reached() const { return m_state; }
46
47 Timeout() : m_state(false) {}
48
49 private:
50 std::atomic<bool> m_state;
51 void set() { m_state = true; }
52 void reset() { m_state = false; }
53
54 // Prevent direct instantiation
57 };
58
59 inline Timeout& Timeout::instance (const EventContext& ctx) {
61 return *instances.get (ctx);
62 }
63
65 return instance (Gaudi::Hive::currentContext());
66 }
67
68
90
91} // namespace Athena
92
93#endif
Maintain a set of objects, one per slot.
std::map< std::string, double > instance
#define ATLAS_THREAD_SAFE
Class to modify timeout flag.
Definition Timeout.h:77
TimeoutMaster()
Prevent direct instantiation.
Definition Timeout.h:86
TimeoutMaster(TimeoutMaster &)
void resetTimeout(Timeout &instance)
Reset timeout.
Definition Timeout.h:83
TimeoutMaster & operator=(const TimeoutMaster &)
void setTimeout(Timeout &instance)
Set timeout.
Definition Timeout.h:80
Singleton to access the timeout flag.
Definition Timeout.h:35
void reset()
Reset timeout flag.
Definition Timeout.h:52
std::atomic< bool > m_state
Timeout flag.
Definition Timeout.h:50
void set()
Set timeout flag.
Definition Timeout.h:51
bool reached() const
Check if the timeout was reached.
Definition Timeout.h:45
Timeout(Timeout &)
friend class TimeoutMaster
Only classes derived from TimeoutMaster can modify timeout flag.
Definition Timeout.h:37
Timeout & operator=(const Timeout &)
static Timeout & instance()
Get reference to Timeout singleton.
Definition Timeout.h:64
Maintain a set of objects, one per slot.
Some weak symbol referencing magic... These are declared in AthenaKernel/getMessageSvc....