OmniSciDB  c07336695a
Catalog_Namespace::sqlite_lock< T > Class Template Reference

#include <RWLocks.h>

Public Member Functions

 sqlite_lock (const T *cat)
 
 ~sqlite_lock ()
 

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 64 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 84 of file RWLocks.h.

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

84  : cat_read_lock(cat), catalog(cat), holds_lock(false) {
85  lock_catalog(cat);
86  }
read_lock< T > cat_read_lock
Definition: RWLocks.h:67
void lock_catalog(const inner_type *cat)
Definition: RWLocks.h:73
+ Here is the call graph for this function:

◆ ~sqlite_lock()

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

Definition at line 88 of file RWLocks.h.

88  {
89  if (holds_lock) {
90  std::thread::id no_thread;
91  catalog->thread_holding_sqlite_lock = no_thread;
92  }
93  }

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 73 of file RWLocks.h.

73  {
74  std::thread::id tid = std::this_thread::get_id();
75 
76  if (cat->thread_holding_sqlite_lock != tid) {
77  lock = std::unique_lock<std::mutex>(cat->sqliteMutex_);
78  cat->thread_holding_sqlite_lock = tid;
79  holds_lock = true;
80  }
81  }
std::unique_lock< std::mutex > lock
Definition: RWLocks.h:69

Member Data Documentation

◆ cat_read_lock

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

Definition at line 67 of file RWLocks.h.

◆ catalog

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

Definition at line 68 of file RWLocks.h.

◆ holds_lock

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

Definition at line 70 of file RWLocks.h.

◆ lock

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

Definition at line 69 of file RWLocks.h.


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