ATLAS Offline Software
Public Member Functions | Static Public Member Functions | Static Protected Attributes | Private Member Functions | Private Attributes | List of all members
oh_lock_histogram< H > Class Template Reference

Lock to be used for thread unsafe histogram operations. More...

#include <OHLockedHist.h>

Inheritance diagram for oh_lock_histogram< H >:
Collaboration diagram for oh_lock_histogram< H >:

Public Member Functions

 oh_lock_histogram (H *h)
 Lock. More...
 
Hoperator-> ()
 Access to histogram pointer. More...
 
 ~oh_lock_histogram ()
 Unlock. More...
 

Static Public Member Functions

static void set_histogram_mutex (std::mutex &mutex)
 Set mutex to be used in oh_lock_histogram. More...
 
static void reset_histogram_mutex ()
 Reset (disable) histogram mutex. More...
 

Static Protected Attributes

static std::mutex *m_mutex ATLAS_THREAD_SAFE
 

Private Member Functions

void * operator new (size_t)
 Do not allow dynamic allocation to avoid accidental deadlocks. More...
 

Private Attributes

Hm_hist
 

Detailed Description

template<class H>
class oh_lock_histogram< H >

Lock to be used for thread unsafe histogram operations.

The TH1::Fill and other operations may sometimes involve ROOT global variables access. This usually leads to crashes as the histogram may be accessed at the same time for OH publication.

This usually happens when histograms have labeled bins, but may also happen in other cases involving re-binning, cloning etc. For those (and only those) operations one should lock the histogram access via the OH mutex:

TH1F * myhistogram = new ....
// instead of myhistogram->Fill("blabla")
oh_lock_histogram<TH1F>(myhistogram)->Fill("blabla");

Definition at line 69 of file OHLockedHist.h.

Constructor & Destructor Documentation

◆ oh_lock_histogram()

template<class H >
oh_lock_histogram< H >::oh_lock_histogram ( H h)
inline

Lock.

Definition at line 72 of file OHLockedHist.h.

72  : m_hist(h)
73  {
74  if (m_mutex) m_mutex->lock();
75  }

◆ ~oh_lock_histogram()

template<class H >
oh_lock_histogram< H >::~oh_lock_histogram ( )
inline

Unlock.

Definition at line 81 of file OHLockedHist.h.

82  {
83  if (m_mutex) m_mutex->unlock();
84  }

Member Function Documentation

◆ operator new()

template<class H >
void* oh_lock_histogram< H >::operator new ( size_t  )
private

Do not allow dynamic allocation to avoid accidental deadlocks.

◆ operator->()

template<class H >
H* oh_lock_histogram< H >::operator-> ( )
inline

Access to histogram pointer.

Definition at line 78 of file OHLockedHist.h.

78 { return m_hist; }

◆ reset_histogram_mutex()

static void oh_lock_histogram_mutex::reset_histogram_mutex ( )
inlinestaticinherited

Reset (disable) histogram mutex.

Definition at line 39 of file OHLockedHist.h.

39 { m_mutex = nullptr; }

◆ set_histogram_mutex()

static void oh_lock_histogram_mutex::set_histogram_mutex ( std::mutex &  mutex)
inlinestaticinherited

Set mutex to be used in oh_lock_histogram.

Definition at line 36 of file OHLockedHist.h.

36 { m_mutex = &mutex; }

Member Data Documentation

◆ ATLAS_THREAD_SAFE

std::mutex* m_mutex oh_lock_histogram_mutex::ATLAS_THREAD_SAFE
staticprotectedinherited

Definition at line 46 of file OHLockedHist.h.

◆ m_hist

template<class H >
H* oh_lock_histogram< H >::m_hist
private

Definition at line 90 of file OHLockedHist.h.


The documentation for this class was generated from the following file:
BeamSpot::mutex
std::mutex mutex
Definition: InDetBeamSpotVertex.cxx:18
oh_lock_histogram
Lock to be used for thread unsafe histogram operations.
Definition: OHLockedHist.h:69
h
python.TrigEgammaMonitorHelper.TH1F
def TH1F(name, title, nxbins, bins_par2, bins_par3=None, path='', **kwargs)
Definition: TrigEgammaMonitorHelper.py:24
oh_lock_histogram::m_hist
H * m_hist
Definition: OHLockedHist.h:90