Zero  0.1.0
w_okvl.h
Go to the documentation of this file.
1 /*
2  * (c) Copyright 2013-, Hewlett-Packard Development Company, LP
3  */
4 #ifndef __W_OKVL_H
5 #define __W_OKVL_H
6 
59 #include <cstring> // for memset/memcpy/memcmp
60 #include <cstdint>
61 
78 const uint32_t OKVL_PARTITIONS = 2; // 127; // 29;
79 
84 const uint32_t OKVL_MODE_COUNT = (OKVL_PARTITIONS + 1 + 1);
85 
95 struct okvl_mode {
97  typedef uint16_t part_id;
98 
107  enum element_lock_mode { N = 0, IS, IX, S, SIX, X, COUNT,
115  };
116 
122  unsigned char modes[OKVL_MODE_COUNT];
123 
125  okvl_mode();
126 
128  okvl_mode(const okvl_mode& r);
129 
131  okvl_mode& operator=(const okvl_mode& r);
132 
134  okvl_mode(element_lock_mode key_mode, element_lock_mode gap_mode);
135 
137  okvl_mode(part_id part, element_lock_mode partition_mode);
138 
139  element_lock_mode get_partition_mode(part_id partition) const;
140 
142 
144 
146  bool is_empty() const;
147 
149  bool is_keylock_empty() const;
150 
152  bool is_keylock_partition_empty() const;
153 
164  bool contains_dirty_lock() const;
165 
166  // Return whether this contains dirty lock on key, not gap
167  bool contains_dirty_key_lock() const;
168 
170  void set_partition_mode(part_id partition, element_lock_mode mode);
171 
173  void set_key_mode(element_lock_mode mode);
174 
176  void set_gap_mode(element_lock_mode mode);
177 
179  void clear();
180 
182  bool is_compatible_request(const okvl_mode& requested) const;
183 
185  bool is_compatible_grant(const okvl_mode& granted) const;
186 
195  bool is_implied_by(const okvl_mode& superset) const;
196 
198  bool operator==(const okvl_mode& r) const;
199 
200  bool operator!=(const okvl_mode& r) const;
201 
203  static bool is_compatible(const okvl_mode& requested, const okvl_mode& granted);
204 
206  static bool is_compatible_element(element_lock_mode requested, element_lock_mode granted);
207 
213 
215  static part_id compute_part_id(const void* uniquefier, int uniquefier_length);
216 
221  static okvl_mode combine(const okvl_mode& left, const okvl_mode& right);
222 
223 private:
226  WORD_SIZE = sizeof(uint64_t),
227  };
228 
230  static bool _can_batch64(part_id part);
231 
233  uint64_t _get_batch64(part_id part) const;
234 
236  uint64_t& _get_batch64_ref(part_id part);
237 };
238 
239 #endif // __W_OKVL_H
element_lock_mode get_gap_mode() const
Definition: w_okvl_inl.h:170
void set_key_mode(element_lock_mode mode)
Definition: w_okvl_inl.h:239
unsigned char modes[OKVL_MODE_COUNT]
Definition: w_okvl.h:122
void set_partition_mode(part_id partition, element_lock_mode mode)
Definition: w_okvl_inl.h:231
bool operator==(const okvl_mode &r) const
Definition: w_okvl_inl.h:398
uint64_t & _get_batch64_ref(part_id part)
Definition: w_okvl_inl.h:198
bool is_compatible_request(const okvl_mode &requested) const
Definition: w_okvl_inl.h:251
Definition: w_okvl.h:113
bool is_empty() const
Definition: w_okvl_inl.h:174
static bool is_implied_by_element(element_lock_mode left, element_lock_mode right)
Definition: w_okvl_inl.h:128
element_lock_mode get_key_mode() const
Definition: w_okvl_inl.h:166
Definition: w_okvl.h:112
static bool is_compatible(const okvl_mode &requested, const okvl_mode &granted)
Definition: w_okvl_inl.h:261
element_lock_mode
Lock mode for one OKVL component (key, partition, or gap).
Definition: w_okvl.h:107
static bool is_compatible_element(element_lock_mode requested, element_lock_mode granted)
Definition: w_okvl_inl.h:122
bool contains_dirty_lock() const
Returns whether this contains any lock mode that implies data update directly in the resource this lo...
Definition: w_okvl_inl.h:202
const uint32_t OKVL_MODE_COUNT
Definition: w_okvl.h:84
void clear()
Definition: w_okvl_inl.h:247
bool is_keylock_empty() const
Definition: w_okvl_inl.h:180
Definition: w_okvl.h:108
bool is_implied_by(const okvl_mode &superset) const
Definition: w_okvl_inl.h:305
uint16_t part_id
Definition: w_okvl.h:97
element_lock_mode get_partition_mode(part_id partition) const
Definition: w_okvl_inl.h:162
okvl_mode()
Definition: w_okvl_inl.h:134
okvl_mode & operator=(const okvl_mode &r)
Definition: w_okvl_inl.h:142
bool is_keylock_partition_empty() const
Definition: w_okvl_inl.h:185
Represents a lock mode of one key entry in the OKVL lock manager.
Definition: w_okvl.h:95
uint64_t _get_batch64(part_id part) const
Definition: w_okvl_inl.h:194
bool is_compatible_grant(const okvl_mode &granted) const
Definition: w_okvl_inl.h:256
static okvl_mode combine(const okvl_mode &left, const okvl_mode &right)
Definition: w_okvl_inl.h:353
bool contains_dirty_key_lock() const
Definition: w_okvl_inl.h:213
Definition: w_okvl.h:109
Definition: w_okvl.h:114
static bool _can_batch64(part_id part)
Definition: w_okvl_inl.h:190
const uint32_t OKVL_PARTITIONS
The number of partitions in OKVL.
Definition: w_okvl.h:78
Definition: w_okvl.h:110
bool operator!=(const okvl_mode &r) const
Definition: w_okvl_inl.h:412
static part_id compute_part_id(const void *uniquefier, int uniquefier_length)
Definition: w_okvl_inl.h:336
void set_gap_mode(element_lock_mode mode)
Definition: w_okvl_inl.h:243
Definition: w_okvl.h:226
const_values_enum
Definition: w_okvl.h:225
Definition: w_okvl.h:111