ATLAS Offline Software
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 
22 
23 #include <mutex>
24 
31 public:
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 
45 protected:
46  static std::mutex* m_mutex ATLAS_THREAD_SAFE;
47 };
48 
68 template <class H>
70 public:
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 
86 private:
88  void* operator new(size_t);
89 
91 };
92 
109 public:
112  {
113  if (m_mutex) m_mutex->lock();
114  }
115 
118  {
119  if (m_mutex) m_mutex->unlock();
120  }
121 
122 private:
124  void* operator new(size_t);
125 };
126 
127 #endif
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
oh_lock_histogram_mutex
Helper class to set histogram mutex.
Definition: OHLockedHist.h:30
oh_lock_histogram_mutex::oh_lock_histogram_mutex
oh_lock_histogram_mutex()=default
oh_lock_histogram_mutex::oh_lock_histogram_mutex
oh_lock_histogram_mutex(const oh_lock_histogram_mutex &)=delete
oh_lock_histogram
Lock to be used for thread unsafe histogram operations.
Definition: OHLockedHist.h:69
oh_scoped_lock_histogram
Scoped lock to be used for threaded histogram operations.
Definition: OHLockedHist.h:108
oh_lock_histogram_mutex::operator=
oh_lock_histogram_mutex & operator=(const oh_lock_histogram_mutex &)=delete
oh_lock_histogram_mutex::ATLAS_THREAD_SAFE
static std::mutex *m_mutex ATLAS_THREAD_SAFE
Definition: OHLockedHist.h:46
H
#define H(x, y, z)
Definition: MD5.cxx:114
oh_lock_histogram::~oh_lock_histogram
~oh_lock_histogram()
Unlock.
Definition: OHLockedHist.h:81
oh_lock_histogram::oh_lock_histogram
oh_lock_histogram(H *h)
Lock.
Definition: OHLockedHist.h:72
oh_lock_histogram_mutex::reset_histogram_mutex
static void reset_histogram_mutex()
Reset (disable) histogram mutex.
Definition: OHLockedHist.h:39
oh_lock_histogram::operator->
H * operator->()
Access to histogram pointer.
Definition: OHLockedHist.h:78
oh_scoped_lock_histogram::~oh_scoped_lock_histogram
~oh_scoped_lock_histogram()
Unlock.
Definition: OHLockedHist.h:117
h
oh_scoped_lock_histogram::oh_scoped_lock_histogram
oh_scoped_lock_histogram()
Lock.
Definition: OHLockedHist.h:111
oh_lock_histogram_mutex::set_histogram_mutex
static void set_histogram_mutex(std::mutex &mutex)
Set mutex to be used in oh_lock_histogram.
Definition: OHLockedHist.h:36
checker_macros.h
Define macros for attributes used to control the static checker.
oh_lock_histogram::m_hist
H * m_hist
Definition: OHLockedHist.h:90
oh_lock_histogram_mutex::~oh_lock_histogram_mutex
~oh_lock_histogram_mutex()=default