Belle II Software  release-08-01-10
LockGuard.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 #ifndef _Belle2_LockGuard_hh
9 #define _Belle2_LockGuard_hh
10 
11 #include <daq/slc/system/Mutex.h>
12 #include "MMutex.h"
13 
14 namespace Belle2 {
46  template<class AMutex>
48  public:
50  explicit GenericLockGuard(AMutex& mutex) : m_mutex(mutex)
51  {
52  m_mutex.lock();
53  }
54 
57  {
58  m_mutex.unlock();
59  }
60 
61  private:
64 
67 
69  AMutex& m_mutex;
70  };
71 
75 }
76 
77 #endif
Lock Guard for a Mutex instance.
Definition: LockGuard.h:47
GenericLockGuard(AMutex &mutex)
Construct a new LockGuard locking the mutex.
Definition: LockGuard.h:50
AMutex & m_mutex
The mutex hold by this lock guard.
Definition: LockGuard.h:69
GenericLockGuard(const GenericLockGuard &)
Do not allow to copy a lock guard.
~GenericLockGuard()
Automatically release the lock on destruction.
Definition: LockGuard.h:56
GenericLockGuard & operator=(const GenericLockGuard &)
Do not allow to copy a lock guard.
Abstract base class for different kinds of events.