OmniSciDB  b24e664e58
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Lock_Namespace::TableLockMgrImpl< T > Class Template Reference

#include <TableLockMgr.h>

Public Member Functions

MutexTypegetTableMutex (const ChunkKey table_key)
 

Static Public Member Functions

static void getTableLocks (const Catalog_Namespace::Catalog &cat, const std::map< std::string, bool > &table_names, std::vector< TableLock > &table_locks)
 
static void getTableLocks (const Catalog_Namespace::Catalog &cat, const std::string &query_ra, std::vector< TableLock > &table_locks)
 
static WriteLock getWriteLockForTable (const Catalog_Namespace::Catalog &cat, const std::string &table_name)
 
static WriteLock getWriteLockForTable (const ChunkKey table_key)
 
static ReadLock getReadLockForTable (const Catalog_Namespace::Catalog &cat, const std::string &table_name)
 
static ReadLock getReadLockForTable (const ChunkKey table_key)
 

Protected Member Functions

 TableLockMgrImpl ()
 

Protected Attributes

std::mutex map_mutex_
 
std::map< ChunkKey, MutexTypetable_mutex_map_
 

Detailed Description

template<class T>
class Lock_Namespace::TableLockMgrImpl< T >

Definition at line 56 of file TableLockMgr.h.

Constructor & Destructor Documentation

template<class T>
Lock_Namespace::TableLockMgrImpl< T >::TableLockMgrImpl ( )
inlineprotected

Definition at line 105 of file TableLockMgr.h.

105 {}

Member Function Documentation

template<class T>
static ReadLock Lock_Namespace::TableLockMgrImpl< T >::getReadLockForTable ( const Catalog_Namespace::Catalog cat,
const std::string &  table_name 
)
inlinestatic

Definition at line 95 of file TableLockMgr.h.

96  {
97  return Lock_Helpers::getLockForTableImpl<ReadLock, T>(cat, table_name);
98  }
template<class T>
static ReadLock Lock_Namespace::TableLockMgrImpl< T >::getReadLockForTable ( const ChunkKey  table_key)
inlinestatic

Definition at line 99 of file TableLockMgr.h.

99  {
100  auto& table_lock_mgr = T::instance();
101  return ReadLock(table_lock_mgr.getTableMutex(table_key));
102  }
mapd_shared_lock< MutexType > ReadLock
Definition: TableLockMgr.h:48
template<class T>
static void Lock_Namespace::TableLockMgrImpl< T >::getTableLocks ( const Catalog_Namespace::Catalog cat,
const std::map< std::string, bool > &  table_names,
std::vector< TableLock > &  table_locks 
)
inlinestatic

Definition at line 63 of file TableLockMgr.h.

65  {
66  for (const auto& table_name_itr : table_names) {
67  TableLock table_lock;
68  if (table_name_itr.second) {
69  table_lock.write_lock = T::getWriteLockForTable(cat, table_name_itr.first);
70  } else {
71  table_lock.read_lock = T::getReadLockForTable(cat, table_name_itr.first);
72  }
73  table_locks.emplace_back(std::move(table_lock));
74  }
75  }
template<class T>
static void Lock_Namespace::TableLockMgrImpl< T >::getTableLocks ( const Catalog_Namespace::Catalog cat,
const std::string &  query_ra,
std::vector< TableLock > &  table_locks 
)
inlinestatic

Definition at line 77 of file TableLockMgr.h.

79  {
80  // parse ra to learn involved table names
81  std::map<std::string, bool> table_names;
82  getTableNames(table_names, query_ra);
83  return T::getTableLocks(cat, table_names, table_locks);
84  }
void getTableNames(std::map< std::string, bool > &tableNames, const std::string query_ra)
Definition: LockMgr.cpp:27
void getTableLocks(const Catalog_Namespace::Catalog &cat, const std::map< std::string, bool > &tableNames, std::vector< std::shared_ptr< LockTypeContainer >> &tableLocks, const Lock_Namespace::LockType lockType)
Definition: LockMgr.h:97
template<class T>
MutexType& Lock_Namespace::TableLockMgrImpl< T >::getTableMutex ( const ChunkKey  table_key)
inline

Definition at line 58 of file TableLockMgr.h.

58  {
59  std::lock_guard<std::mutex> access_map_lock(map_mutex_);
60  return table_mutex_map_[table_key];
61  }
std::map< ChunkKey, MutexType > table_mutex_map_
Definition: TableLockMgr.h:108
template<class T>
static WriteLock Lock_Namespace::TableLockMgrImpl< T >::getWriteLockForTable ( const Catalog_Namespace::Catalog cat,
const std::string &  table_name 
)
inlinestatic

Definition at line 86 of file TableLockMgr.h.

87  {
88  return Lock_Helpers::getLockForTableImpl<WriteLock, T>(cat, table_name);
89  }
template<class T>
static WriteLock Lock_Namespace::TableLockMgrImpl< T >::getWriteLockForTable ( const ChunkKey  table_key)
inlinestatic

Definition at line 90 of file TableLockMgr.h.

90  {
91  auto& table_lock_mgr = T::instance();
92  return WriteLock(table_lock_mgr.getTableMutex(table_key));
93  }
mapd_unique_lock< MutexType > WriteLock
Definition: TableLockMgr.h:47

Member Data Documentation

template<class T>
std::mutex Lock_Namespace::TableLockMgrImpl< T >::map_mutex_
protected
template<class T>
std::map<ChunkKey, MutexType> Lock_Namespace::TableLockMgrImpl< T >::table_mutex_map_
protected

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