ATLAS Offline Software
Loading...
Searching...
No Matches
threading.h
Go to the documentation of this file.
1// This file's extension implies that it's C, but it's really -*- C++ -*-.
2/*
3 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
4*/
15
16
17#ifndef ATHCONTAINERS_THREADING_H
18#define ATHCONTAINERS_THREADING_H
19
20
21#ifdef ATHCONTAINERS_NO_THREADS
22
23
24namespace AthContainers_detail {
25
26
30class mutex {};
31
32
36class recursive_mutex {};
37
38
42template <class LOCKABLE>
43class lock_guard
44{
45public:
46 lock_guard() {}
47 lock_guard(LOCKABLE&) {}
48};
49
50
52inline void fence_acq_rel() {}
53inline void fence_seq_cst() {}
54
55
57template <class T>
58class atomic
59{
60public:
61 atomic() : m_val() {}
62 operator T() const { return m_val; }
63 atomic& operator= (const T& val) { m_val = val; return *this; }
64
65private:
66 T m_val;
67};
68
69
70} // namespace AthContainers_detail
71
72
73#else // not ATHCONTAINERS_NO_THREADS
74
75//the shared_mutex include generates annoying unused_variable warnings during compilations... silence this in athanalysisbase
76#ifdef XAOD_ANALYSIS
77#ifndef BOOST_SYSTEM_NO_DEPRECATED
78#define BOOST_SYSTEM_NO_DEPRECATED 1
79#endif
80#endif
81
82
83#include <atomic>
84#include <mutex>
85#include <thread>
86
87
88namespace AthContainers_detail {
89
90
91using std::mutex;
92using std::recursive_mutex;
93using std::lock_guard;
94using std::thread;
95using std::atomic;
96
97
102
103
108
109
110} // namespace AthContainers_detail
111
112
113#endif // not ATHCONTAINERS_NO_THREADS
114
115
116
117namespace AthContainers_detail {
118
119
126template <typename LOCKABLE>
128{
129public:
131 typedef LOCKABLE lockable_type;
132
133
139
140
145 explicit strict_shared_lock(const lockable_type& obj);
146
147
152
153
154private:
155 // Disallow these.
159
160
161private:
164};
165
166
175template <class LOCKABLE>
177{
178public:
180 typedef LOCKABLE lockable_type;
181
182
188
189
194
195
199 void upgrade();
200
201
202private:
203 // Disallow these.
207
208
209private:
212
215};
216
217
218} // namespace AthContainers_detail
219
220
222
223
224#endif // not ATHCONTAINERS_THREADING_H
lockable_type & m_obj
The lock being held.
Definition threading.h:163
strict_shared_lock(strict_shared_lock const &)
strict_shared_lock(lockable_type &obj)
Take out a shared lock on obj and remember it.
strict_shared_lock(const lockable_type &obj)
Take out a shared lock on obj and remember it.
~strict_shared_lock()
Release the held lock.
strict_shared_lock & operator=(strict_shared_lock const &)
LOCKABLE lockable_type
The underlying object type.
Definition threading.h:131
upgrading_lock(upgrading_lock const &)
~upgrading_lock()
Release the held lock.
upgrading_lock & operator=(upgrading_lock const &)
LOCKABLE lockable_type
The underlying object type.
Definition threading.h:180
void upgrade()
Convert the lock from upgrade to exclusive.
upgrading_lock(lockable_type &obj)
Take out an upgrade lock on obj and remember it.
void fence_seq_cst()
A sequentially-consistent fence.
void fence_acq_rel()
An acquire/release fence.
unsigned long long T