Zero  0.1.0
lock_x.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2011-2014, Hewlett-Packard Development Company, LP
3  */
4 
5 #ifndef __LOCK_X_H
6 #define __LOCK_X_H
7 
8 #include "w_defines.h"
9 
10 class xct_lock_info_t; // forward
11 class lock_queue_entry_t;
12 class lock_queue_t;
13 class okvl_mode;
14 class lockid_t;
15 
24 public:
25  xct_lock_entry_t() : prev(nullptr),
26  next(nullptr),
27  private_hashmap_prev(nullptr),
28  private_hashmap_next(nullptr),
29  queue(nullptr),
30  entry(nullptr) {}
31 
32  // doubly linked list
34 
36 
37  // another doubly linked list for XctLockHashMap
39 
41 
42  // Corresponding object in lock queue.
44 
46 };
47 
53 const int XCT_LOCK_HASHMAP_SIZE = 1023;
54 
84 public:
86 
87  ~XctLockHashMap();
88 
95  const okvl_mode& get_granted_mode(uint32_t lock_id) const;
96 
98  void reset();
99 
101  void push_front(xct_lock_entry_t* link);
102 
104  void remove(xct_lock_entry_t* link);
105 
106 private:
107 
112 
114  static uint32_t _bucket_id(uint32_t lock_id) {
115  return lock_id % XCT_LOCK_HASHMAP_SIZE;
116  }
117 };
118 
127 class xct_lock_info_t : private smlevel_0 {
128 
129 public:
130  xct_lock_info_t();
131 
132  ~xct_lock_info_t();
133 
137  xct_lock_info_t* reset_for_reuse();
138 
140  friend ostream& operator<<(ostream& o, const xct_lock_info_t& x);
141 
143  ostream& dump_locks(ostream& out) const;
144 
146  tid_t tid() const {
147  return _tid;
148  }
149 
151  void set_tid(const tid_t& t) {
152  _tid = t;
153  }
154 
156  // atomic_thread_map_t const &get_wait_map() const { return _wait_map; }
157  // void clear_wait_map() {
158  // //_wait_map.lock_for_write();
159  // _wait_map.clear();
160  // //_wait_map.unlock_writer();
161  // }
162  // void refresh_wait_map(atomic_thread_map_t const &new_map) {
163  // _wait_map.copy(new_map);
164  // }
165  // void init_wait_map(smthread_t *thr) {
166  // //_wait_map.lock_for_write();
167  // _wait_map.copy(thr->get_fingerprint_map());
168  // //_wait_map.unlock_writer();
169  // DBGOUT5 (<< "initialized wait map!" << _wait_map);
170  // }
171 
173 
174  void remove_request(xct_lock_entry_t* entry);
175 
178  return _hashmap;
179  }
180 
181 public:
182  /*
183  * List of locks acquired by this xct.
184  */
186 
188 
193 
195 
197 
199 
200 private:
201  // tid of the most recent transaction using this lock_info; monotonically
202  // increasing.
204 
205  atomic_thread_map_t _wait_map; // for dreadlocks DLD
206 };
207 
208 #endif // __LOCK_X_H /*</std-footer>*/
const int XCT_LOCK_HASHMAP_SIZE
Definition: lock_x.h:53
lsn_t _commit_lsn
Definition: lock_x.h:198
A lock request entry in a lock queue.
Definition: lock_bucket.h:47
sm_thread_map_t atomic_thread_map_t
Fingerprint for this smthread.
Definition: smthread.h:89
XctLockHashMap & get_private_hashmap()
Definition: lock_x.h:177
Locking-related status of one transaction.
Definition: lock_x.h:127
A lock entry in transaction&#39;s private memory.
Definition: lock_x.h:23
lock_queue_t * queue
Definition: lock_x.h:43
tid_t tid() const
ID of the transaction that owns this structure.
Definition: lock_x.h:146
XctLockHashMap _hashmap
Definition: lock_x.h:192
xct_lock_entry_t * prev
Definition: lock_x.h:33
A lock queue to hold granted and waiting lock requests (lock_queue_entry_t&#39;s) for a given lock...
Definition: lock_bucket.h:122
xct_lock_entry_t * private_hashmap_prev
Definition: lock_x.h:38
xct_lock_entry_t * _head
Definition: lock_x.h:185
Log Sequence Number. See Log Sequence Numbers (LSN).
Definition: lsn.h:243
A hashmap for lock entries in transaction&#39;s private memory.
Definition: lock_x.h:83
xct_lock_entry_t()
Definition: lock_x.h:25
xct_lock_entry_t * private_hashmap_next
Definition: lock_x.h:40
std::ostream & operator<<(std::ostream &os, const ConfigFile &cf)
Definition: confparser.cpp:83
void set_tid(const tid_t &t)
See above.
Definition: lock_x.h:151
tid_t _tid
Definition: lock_x.h:203
Represents a lock mode of one key entry in the OKVL lock manager.
Definition: w_okvl.h:95
atomic_thread_map_t _wait_map
Definition: lock_x.h:205
The means of identifying a desired or held lock.
Definition: lock_s.h:41
lock_queue_entry_t * entry
Definition: lock_x.h:45
xct_lock_entry_t * _tail
Definition: lock_x.h:187
xct_lock_entry_t * next
Definition: lock_x.h:35
uint64_t tid_t
Definition: tid_t.h:59
bool _permission_to_violate
Definition: lock_x.h:196
static uint32_t _bucket_id(uint32_t lock_id)
Definition: lock_x.h:114
srwlock_t _shared_latch
Definition: lock_x.h:194
Shore read-write lock:: many-reader/one-writer spin lock.
Definition: latches.h:350