ATLAS Offline Software
DBLock.h
Go to the documentation of this file.
1 // This file's extension implies that it's C, but it's really -*- C++ -*-.
2 /*
3  * Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration.
4  */
13 #ifndef DBLOCK_DBLOCK_H
14 #define DBLOCK_DBLOCK_H
15 
16 
17 #include <mutex>
18 #include <memory>
19 
20 
21 namespace Athena {
22 
23 
45 class DBLock
46 {
47 public:
48  DBLock();
49  DBLock(const DBLock&) = default;
50  DBLock(DBLock&&) = default;
51  DBLock& operator=(const DBLock&) = default;
52  DBLock& operator=(DBLock&&) = default;
53  ~DBLock();
54 
55 
56 private:
58  static std::recursive_mutex m_mutex;
59 
62  using lock_t = std::unique_lock<std::recursive_mutex>;
63  std::shared_ptr<lock_t> m_lockPtr;
64 };
65 
66 
67 } // namespace Athena
68 
69 
70 #endif // not DBLOCK_DBLOCK_H
Athena::DBLock::DBLock
DBLock(const DBLock &)=default
Athena::DBLock::operator=
DBLock & operator=(const DBLock &)=default
Athena::DBLock::operator=
DBLock & operator=(DBLock &&)=default
Athena::DBLock::m_lockPtr
std::shared_ptr< lock_t > m_lockPtr
Definition: DBLock.h:63
Athena::DBLock::DBLock
DBLock()
Constructor.
Definition: DBLock.cxx:25
Athena
Some weak symbol referencing magic...
Definition: AthLegacySequence.h:21
Athena::DBLock
Common database lock.
Definition: DBLock.h:46
Athena::DBLock::lock_t
std::unique_lock< std::recursive_mutex > lock_t
Shared pointer to underlying lock.
Definition: DBLock.h:62
Athena::DBLock::DBLock
DBLock(DBLock &&)=default
Athena::DBLock::~DBLock
~DBLock()
Destructor.
Definition: DBLock.cxx:34
Athena::DBLock::m_mutex
static std::recursive_mutex m_mutex
Global mutex to protect database access.
Definition: DBLock.h:58