|
Zero
0.1.0
|
Represents a lock mode of one key entry in the OKVL lock manager. More...
#include <w_okvl.h>
Public Types | |
| enum | element_lock_mode { N = 0, IS, IX, S, SIX, X, COUNT } |
| Lock mode for one OKVL component (key, partition, or gap). More... | |
| typedef uint16_t | part_id |
Public Member Functions | |
| okvl_mode () | |
| okvl_mode (const okvl_mode &r) | |
| okvl_mode & | operator= (const okvl_mode &r) |
| okvl_mode (element_lock_mode key_mode, element_lock_mode gap_mode) | |
| okvl_mode (part_id part, element_lock_mode partition_mode) | |
| element_lock_mode | get_partition_mode (part_id partition) const |
| element_lock_mode | get_key_mode () const |
| element_lock_mode | get_gap_mode () const |
| bool | is_empty () const |
| bool | is_keylock_empty () const |
| bool | is_keylock_partition_empty () const |
| bool | contains_dirty_lock () const |
| Returns whether this contains any lock mode that implies data update directly in the resource this lock protects (e.g., XN. XX, NX etc). More... | |
| bool | contains_dirty_key_lock () const |
| void | set_partition_mode (part_id partition, element_lock_mode mode) |
| void | set_key_mode (element_lock_mode mode) |
| void | set_gap_mode (element_lock_mode mode) |
| void | clear () |
| bool | is_compatible_request (const okvl_mode &requested) const |
| bool | is_compatible_grant (const okvl_mode &granted) const |
| bool | is_implied_by (const okvl_mode &superset) const |
| bool | operator== (const okvl_mode &r) const |
| bool | operator!= (const okvl_mode &r) const |
Static Public Member Functions | |
| static bool | is_compatible (const okvl_mode &requested, const okvl_mode &granted) |
| static bool | is_compatible_element (element_lock_mode requested, element_lock_mode granted) |
| static bool | is_implied_by_element (element_lock_mode left, element_lock_mode right) |
| static part_id | compute_part_id (const void *uniquefier, int uniquefier_length) |
| static okvl_mode | combine (const okvl_mode &left, const okvl_mode &right) |
Public Attributes | |
| unsigned char | modes [OKVL_MODE_COUNT] |
Private Types | |
| enum | const_values_enum { WORD_SIZE = sizeof(uint64_t) } |
Private Member Functions | |
| uint64_t | _get_batch64 (part_id part) const |
| uint64_t & | _get_batch64_ref (part_id part) |
Static Private Member Functions | |
| static bool | _can_batch64 (part_id part) |
Represents a lock mode of one key entry in the OKVL lock manager.
It consists of lock mode for paritions, 1 key, and 1 gap after the key. There are constant instances to quickly get frequently-used lock modes. Otherwise, you have to instantiate this struct. Hope it fits on stack.
| typedef uint16_t okvl_mode::part_id |
typedef for readability. it's just an integer.
|
private |
Lock mode for one OKVL component (key, partition, or gap).
This enum must be up to 256 entries because we assume it's stored in char. Unlike the original shore-mt's enum, the order of the entries imply NOTHING. (well, lock modes only have partitial orders, anyways)
| Enumerator | |
|---|---|
| N | no lock |
| IS | intention share (read) |
| IX | intention exclusive (write) |
| S | share (read) |
| SIX | share with intention exclusive |
| X | exclusive (write) |
| COUNT | Dummy entry to tell # of entries |
|
inline |
Empty constructor that puts N for all partitions and gap.
|
inline |
Copy constructor.
|
inline |
Sets only the key mode and gap mode.
|
inline |
Sets only an individual partition mode (and its intent mode on key).
|
inlinestaticprivate |
Tells if we can apply the common 64bit-batching technique for the given partition.
|
inlineprivate |
Returns the 64bit-batched lock modes for the given partition.
|
inlineprivate |
Returns the 64bit-batched lock modes for the given partition.
|
inline |
Clears all lock modes to be No-Lock.
Returns the lock mode after combining the two lock modes. e.g., X + S = X, S + IX = SIX, etc.
|
inlinestatic |
Determines the partition for the given uniquefier.
|
inline |
|
inline |
Returns whether this contains any lock mode that implies data update directly in the resource this lock protects (e.g., XN. XX, NX etc).
We call such a lock Dirty Lock. Note that IX is NOT a dirty lock. Only X (or in future increment lock) itself meets the criteria. This check is important for ELR and logging because they have to know whether something has been (or might have been) updated or not.
|
inline |
|
inline |
|
inline |
|
inlinestatic |
Static function to tell whether the two modes are compatible.
|
inlinestatic |
Static function to check if two element lock modes are compatible.
|
inline |
Returns whether this requested mode can be allowed by the given granted mode.
|
inline |
Returns whether this granted mode allows the given requested mode.
|
inline |
Returns whether the lock modes are completely empty (all NULL modes).
|
inline |
Returns whether this mode is implied by the given mode. For example, NNNN_S is implied by NXXX_S and NSSN_S is implied by NXXN_X. Note that "A is not implied by B" does NOT always mean "B is implied by A". NOTE "key=S" is logically implied by "key=IS partition= all S", but this function does not check it to be efficient. Do not use this method if it matters.
|
inlinestatic |
Static function to tell whether left is implied by right. Note that "A is not implied by B" does NOT always mean "B is implied by A".
|
inline |
Returns whether the key modes are completely empty, either key or its partitions.
|
inline |
Returns whether the key modes are either empty or key-mode only (S/X in key).
|
inline |
|
inline |
operator overloads.
|
inline |
Sets the gap mode.
|
inline |
Sets the key mode.
|
inline |
Sets an individual partition mode (and its intent mode on key).
| unsigned char okvl_mode::modes[OKVL_MODE_COUNT] |
Each byte represents the element lock mode for a component. This actually means element_lock_mode[OKVL_MODE_COUNT], but explicitly uses char to make sure it's 1 byte.
1.8.12