OmniSciDB  8a228a1076
Catalog_Namespace::sqlite_lock< T > Class Template Reference

#include <RWLocks.h>

Public Member Functions

 sqlite_lock (const T *cat)
 
 ~sqlite_lock ()
 
void unlock ()
 

Private Member Functions

template<typename inner_type >
void lock_catalog (const inner_type *cat)
 

Private Attributes

read_lock< T > cat_read_lock
 
const T * catalog
 
std::unique_lock< std::mutex > lock
 
bool holds_lock
 

Detailed Description

template<typename T>
class Catalog_Namespace::sqlite_lock< T >

Definition at line 68 of file RWLocks.h.

Constructor & Destructor Documentation

◆ sqlite_lock()

template<typename T >
Catalog_Namespace::sqlite_lock< T >::sqlite_lock ( const T *  cat)
inline

Definition at line 88 of file RWLocks.h.

References Catalog_Namespace::read_lock< T >::lock_catalog().

88  : cat_read_lock(cat), catalog(cat), holds_lock(false) {
90  }
std::string cat(Ts &&... args)
read_lock< T > cat_read_lock
Definition: RWLocks.h:71
void lock_catalog(const inner_type *cat)
Definition: RWLocks.h:77
+ Here is the call graph for this function:

◆ ~sqlite_lock()

template<typename T >
Catalog_Namespace::sqlite_lock< T >::~sqlite_lock ( )
inline

Definition at line 92 of file RWLocks.h.

References Catalog_Namespace::read_lock< T >::unlock().

92 { unlock(); }
+ Here is the call graph for this function:

Member Function Documentation

◆ lock_catalog()

template<typename T >
template<typename inner_type >
void Catalog_Namespace::sqlite_lock< T >::lock_catalog ( const inner_type *  cat)
inlineprivate

Definition at line 77 of file RWLocks.h.

77  {
78  std::thread::id tid = std::this_thread::get_id();
79 
80  if (cat->thread_holding_sqlite_lock != tid) {
81  lock = std::unique_lock<std::mutex>(cat->sqliteMutex_);
82  cat->thread_holding_sqlite_lock = tid;
83  holds_lock = true;
84  }
85  }
std::string cat(Ts &&... args)
std::unique_lock< std::mutex > lock
Definition: RWLocks.h:73

◆ unlock()

template<typename T >
void Catalog_Namespace::sqlite_lock< T >::unlock ( )
inline

Definition at line 94 of file RWLocks.h.

References Catalog_Namespace::read_lock< T >::unlock().

Referenced by Catalog_Namespace::Catalog::createDashboard(), and Catalog_Namespace::Catalog::replaceDashboard().

94  {
95  if (holds_lock) {
96  std::thread::id no_thread;
97  catalog->thread_holding_sqlite_lock = no_thread;
98  lock.unlock();
99  cat_read_lock.unlock();
100  holds_lock = false;
101  }
102  }
std::unique_lock< std::mutex > lock
Definition: RWLocks.h:73
read_lock< T > cat_read_lock
Definition: RWLocks.h:71
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ cat_read_lock

template<typename T >
read_lock<T> Catalog_Namespace::sqlite_lock< T >::cat_read_lock
private

Definition at line 71 of file RWLocks.h.

◆ catalog

template<typename T >
const T* Catalog_Namespace::sqlite_lock< T >::catalog
private

Definition at line 72 of file RWLocks.h.

◆ holds_lock

template<typename T >
bool Catalog_Namespace::sqlite_lock< T >::holds_lock
private

Definition at line 74 of file RWLocks.h.

◆ lock

template<typename T >
std::unique_lock<std::mutex> Catalog_Namespace::sqlite_lock< T >::lock
private

Definition at line 73 of file RWLocks.h.


The documentation for this class was generated from the following file: