OmniSciDB  b28c0d5765
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Catalog_Namespace::read_lock< T > Class Template Reference

#include <RWLocks.h>

Public Member Functions

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

Private Member Functions

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

Private Attributes

const T * catalog
 
heavyai::shared_lock
< heavyai::shared_mutex
lock
 
heavyai::shared_lock
< heavyai::DistributedSharedMutex
dlock
 
bool holds_lock
 

Detailed Description

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

Definition at line 38 of file RWLocks.h.

Constructor & Destructor Documentation

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

Definition at line 61 of file RWLocks.h.

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

61 : catalog(cat), holds_lock(false) { lock_catalog(cat); }
std::string cat(Ts &&...args)
void lock_catalog(const inner_type *cat)
Definition: RWLocks.h:45

+ Here is the call graph for this function:

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

Definition at line 63 of file RWLocks.h.

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

63 { unlock(); }

+ Here is the call graph for this function:

Member Function Documentation

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

Definition at line 45 of file RWLocks.h.

References Catalog_Namespace::read_lock< T >::dlock, g_multi_instance, Catalog_Namespace::read_lock< T >::holds_lock, and Catalog_Namespace::read_lock< T >::lock.

Referenced by Catalog_Namespace::read_lock< T >::read_lock().

45  {
46  std::thread::id tid = std::this_thread::get_id();
47 
48  if (cat->thread_holding_write_lock != tid && !inner_type::thread_holds_read_lock) {
49  if (!g_multi_instance) {
51  } else {
52  dlock =
54  }
55  inner_type::thread_holds_read_lock = true;
56  holds_lock = true;
57  }
58  }
bool g_multi_instance
Definition: heavyai_locks.h:21
std::string cat(Ts &&...args)
std::shared_lock< T > shared_lock
heavyai::shared_lock< heavyai::DistributedSharedMutex > dlock
Definition: RWLocks.h:41
heavyai::shared_lock< heavyai::shared_mutex > lock
Definition: RWLocks.h:40

+ Here is the caller graph for this function:

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

Definition at line 65 of file RWLocks.h.

References Catalog_Namespace::read_lock< T >::dlock, g_multi_instance, Catalog_Namespace::read_lock< T >::holds_lock, and Catalog_Namespace::read_lock< T >::lock.

Referenced by Catalog_Namespace::Catalog::getMetadataForTable(), Catalog_Namespace::Catalog::getPhysicalTablesDescriptors(), Catalog_Namespace::SysCatalog::syncUserWithRemoteProvider(), Catalog_Namespace::sqlite_lock< T >::unlock(), and Catalog_Namespace::read_lock< T >::~read_lock().

65  {
66  if (holds_lock) {
67  T::thread_holds_read_lock = false;
68  if (!g_multi_instance) {
69  lock.unlock();
70  } else {
71  dlock.unlock();
72  }
73  holds_lock = false;
74  }
75  }
bool g_multi_instance
Definition: heavyai_locks.h:21
heavyai::shared_lock< heavyai::DistributedSharedMutex > dlock
Definition: RWLocks.h:41
heavyai::shared_lock< heavyai::shared_mutex > lock
Definition: RWLocks.h:40

+ Here is the caller graph for this function:

Member Data Documentation

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

Definition at line 39 of file RWLocks.h.

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

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