ATLAS Offline Software
Loading...
Searching...
No Matches
OHLockedHist.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef AthenaMonitoringKernel_OHLockedHist_h
6#define AthenaMonitoringKernel_OHLockedHist_h
7
20
22
23#include <mutex>
24
31public:
34
36 static void set_histogram_mutex(std::mutex& mutex) { m_mutex = &mutex; }
37
39 static void reset_histogram_mutex() { m_mutex = nullptr; }
40
41 // no copy
44
45protected:
46 static std::mutex* m_mutex ATLAS_THREAD_SAFE;
47};
48
68template <class H>
70public:
73 {
74 if (m_mutex) m_mutex->lock();
75 }
76
78 H* operator->() { return m_hist; }
79
82 {
83 if (m_mutex) m_mutex->unlock();
84 }
85
86private:
88 void* operator new(size_t);
89
91};
92
109public:
112 {
113 if (m_mutex) m_mutex->lock();
114 }
115
118 {
119 if (m_mutex) m_mutex->unlock();
120 }
121
122private:
124 void* operator new(size_t);
125};
126
127#endif
#define H(x, y, z)
Definition MD5.cxx:114
Define macros for attributes used to control the static checker.
Header file for AthHistogramAlgorithm.
STL class.
oh_lock_histogram_mutex()=default
oh_lock_histogram_mutex(const oh_lock_histogram_mutex &)=delete
static void reset_histogram_mutex()
Reset (disable) histogram mutex.
static void set_histogram_mutex(std::mutex &mutex)
Set mutex to be used in oh_lock_histogram.
~oh_lock_histogram_mutex()=default
oh_lock_histogram_mutex & operator=(const oh_lock_histogram_mutex &)=delete
static std::mutex *m_mutex ATLAS_THREAD_SAFE
H * operator->()
Access to histogram pointer.
~oh_lock_histogram()
Unlock.
oh_lock_histogram(H *h)
Lock.