Belle II Software  release-05-02-19
LockGuard.h
1 #ifndef _Belle2_LockGuard_hh
2 #define _Belle2_LockGuard_hh
3 
4 #include <daq/slc/system/Mutex.h>
5 #include "MMutex.h"
6 
7 namespace Belle2 {
39  template<class AMutex>
41  public:
43  explicit GenericLockGuard(AMutex& mutex) : m_mutex(mutex)
44  {
45  m_mutex.lock();
46  }
47 
50  {
51  m_mutex.unlock();
52  }
53 
54  private:
57 
60 
62  AMutex& m_mutex;
63  };
64 
68 }
69 
70 #endif
Belle2::GenericLockGuard::~GenericLockGuard
~GenericLockGuard()
Automatically release the lock on destruction.
Definition: LockGuard.h:49
Belle2::GenericLockGuard::GenericLockGuard
GenericLockGuard(AMutex &mutex)
Construct a new LockGuard locking the mutex.
Definition: LockGuard.h:43
Belle2::GenericLockGuard
Lock Guard for a Mutex instance.
Definition: LockGuard.h:40
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::GenericLockGuard::m_mutex
AMutex & m_mutex
The mutex hold by this lock guard.
Definition: LockGuard.h:62
Belle2::GenericLockGuard::operator=
GenericLockGuard & operator=(const GenericLockGuard &)
Do not allow to copy a lock guard.