Zero  0.1.0
lock_core.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2011-2013, Hewlett-Packard Development Company, LP
3  */
4 
5 #ifndef __LOCK_CORE_H
6 #define __LOCK_CORE_H
7 
8 #include <cstdint>
9 #include "lsn.h"
10 
11 struct RawLock;
12 struct RawLockQueue;
13 struct RawXct;
15 
16 template<class T>
17 struct GcPoolForest;
18 class sm_options;
20 class lil_global_table;
21 class vtable_t;
22 class okvl_mode;
23 
31 class lock_core_m {
32 public:
33  lock_core_m(const sm_options& options);
34 
35  ~lock_core_m();
36 
37  int collect(vtable_t&, bool names_too);
38 
39  void assert_empty() const;
40 
41  void dump(std::ostream& o);
42 
44  return _lil_global_table;
45  }
46 
47 public:
81  w_error_codes acquire_lock(RawXct* xct, uint32_t hash, const okvl_mode& mode,
82  bool check, bool wait, bool acquire, int32_t timeout, RawLock** out);
83 
85  w_error_codes retry_acquire(RawLock** lock, bool check_only, int32_t timeout);
86 
87  void release_lock(RawLock* lock, lsn_t commit_lsn = lsn_t::null);
88 
89  void release_duration(bool read_lock_only = false, lsn_t commit_lsn = lsn_t::null);
90 
95 
96  void deallocate_xct(RawXct* xct);
97 
98 private:
99  uint32_t _table_bucket(uint32_t id) const {
100  return id % _htabsz;
101  }
102 
104 
106 
108 
110 
112 
113  uint32_t _htabsz;
114 
117 };
118 
119 // TODO to remove
120 // this is for experiments to compare deadlock detection/recovery methods.
121 #define SWITCH_DEADLOCK_IMPL
122 #ifdef SWITCH_DEADLOCK_IMPL
123 
126 
129 
130 class xct_t;
131 class lock_request_t;
132 
134 extern w_error_codes (* g_check_deadlock_impl)(xct_t* xd, lock_request_t* myreq);
135 
136 #endif // SWITCH_DEADLOCK_IMPL
137 
138 #endif // __LOCK_CORE_H /*</std-footer>*/
void deallocate_xct(RawXct *xct)
Definition: lock_core.cpp:175
lil_global_table * get_lil_global_table()
Definition: lock_core.h:43
Lock table implementation class.
Definition: lock_core.h:31
int collect(vtable_t &, bool names_too)
~lock_core_m()
Definition: lock_core.cpp:136
void assert_empty() const
Definition: lock_dump.cpp:21
Definition: lock_lil.h:147
A shadow transaction object for RAW-style lock manager.
Definition: lock_raw.h:469
A transaction. Internal to the storage manager.This class may be used in a limited way for the handli...
Definition: xct.h:185
The background thread for pre-allocation and garbage collection of object pools used in RAW-style loc...
Definition: lock_raw.h:593
lock_core_m(const sm_options &options)
Definition: lock_core.cpp:48
Start-up parameters for the storage engine. See OPTIONS.
Definition: sm_options.h:24
uint32_t _htabsz
Definition: lock_core.h:113
w_error_codes(* g_check_deadlock_impl)(xct_t *xd, lock_request_t *myreq)
Definition: lock_core.cpp:28
uint32_t _table_bucket(uint32_t id) const
Definition: lock_core.h:99
w_error_codes
Enum of error codes defined in w_error_xmacro.h.
Definition: w_error.h:43
static const lsn_t null
Definition: lsn.h:371
w_error_codes acquire_lock(RawXct *xct, uint32_t hash, const okvl_mode &mode, bool check, bool wait, bool acquire, int32_t timeout, RawLock **out)
Adds a new lock in the given mode to this queue, waiting until it is granted.
Definition: lock_core.cpp:180
int g_deadlock_dreadlock_interval_ms
Definition: lock_core.cpp:26
GcPoolForest< RawXct > * _xct_pool
Definition: lock_core.h:105
void release_lock(RawLock *lock, lsn_t commit_lsn=lsn_t::null)
Definition: lock_core.cpp:232
void dump(std::ostream &o)
Definition: lock_dump.cpp:35
void release_duration(bool read_lock_only=false, lsn_t commit_lsn=lsn_t::null)
Definition: lock_core.cpp:239
Log Sequence Number. See Log Sequence Numbers (LSN).
Definition: lsn.h:243
An RAW-style lock entry in the queue.
Definition: lock_raw.h:133
GcPoolForest< RawLock > * _lock_pool
Definition: lock_core.h:103
RawXct * allocate_xct()
Definition: lock_core.cpp:169
RawLockQueue * _htab
Definition: lock_core.h:111
Garbage-collected Pool Forest.
Definition: w_gc_pool_forest.h:57
RawLockBackgroundThread * _raw_lock_cleaner
Definition: lock_core.h:109
Represents a lock mode of one key entry in the OKVL lock manager.
Definition: w_okvl.h:95
Definition: lock_core.cpp:38
xct_t * xct()
Definition: smthread.h:575
w_error_codes retry_acquire(RawLock **lock, bool check_only, int32_t timeout)
Definition: lock_core.cpp:207
An RAW-style lock queue to hold granted and waiting lock requests (RawLock).
Definition: lock_raw.h:184
lil_global_table * _lil_global_table
Definition: lock_core.h:116
bool g_deadlock_use_waitmap_obsolete
Definition: lock_core.cpp:24
RawLockCleanerFunctor * _raw_lock_cleaner_functor
Definition: lock_core.h:107