Zero  0.1.0
Public Types | Public Member Functions | Static Public Member Functions | Public Attributes | Private Types | Private Member Functions | Static Private Member Functions | List of all members
okvl_mode Struct Reference

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_modeoperator= (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)
 

Detailed Description

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.

Member Typedef Documentation

§ part_id

typedef uint16_t okvl_mode::part_id

typedef for readability. it's just an integer.

Member Enumeration Documentation

§ const_values_enum

We speed up comparisons by batching multiple lock modes into this size.

Enumerator
WORD_SIZE 

§ element_lock_mode

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

no lock

IS 

intention share (read)

IX 

intention exclusive (write)

share (read)

SIX 

share with intention exclusive

exclusive (write)

COUNT 

Dummy entry to tell # of entries

Constructor & Destructor Documentation

§ okvl_mode() [1/4]

okvl_mode::okvl_mode ( )
inline

Empty constructor that puts N for all partitions and gap.

§ okvl_mode() [2/4]

okvl_mode::okvl_mode ( const okvl_mode r)
inline

Copy constructor.

§ okvl_mode() [3/4]

okvl_mode::okvl_mode ( element_lock_mode  key_mode,
element_lock_mode  gap_mode 
)
inline

Sets only the key mode and gap mode.

§ okvl_mode() [4/4]

okvl_mode::okvl_mode ( part_id  part,
element_lock_mode  partition_mode 
)
inline

Sets only an individual partition mode (and its intent mode on key).

Member Function Documentation

§ _can_batch64()

bool okvl_mode::_can_batch64 ( part_id  part)
inlinestaticprivate

Tells if we can apply the common 64bit-batching technique for the given partition.

§ _get_batch64()

uint64_t okvl_mode::_get_batch64 ( part_id  part) const
inlineprivate

Returns the 64bit-batched lock modes for the given partition.

§ _get_batch64_ref()

uint64_t & okvl_mode::_get_batch64_ref ( part_id  part)
inlineprivate

Returns the 64bit-batched lock modes for the given partition.

§ clear()

void okvl_mode::clear ( )
inline

Clears all lock modes to be No-Lock.

§ combine()

okvl_mode okvl_mode::combine ( const okvl_mode left,
const okvl_mode right 
)
inlinestatic

Returns the lock mode after combining the two lock modes. e.g., X + S = X, S + IX = SIX, etc.

§ compute_part_id()

okvl_mode::part_id okvl_mode::compute_part_id ( const void *  uniquefier,
int  uniquefier_length 
)
inlinestatic

Determines the partition for the given uniquefier.

§ contains_dirty_key_lock()

bool okvl_mode::contains_dirty_key_lock ( ) const
inline

§ contains_dirty_lock()

bool okvl_mode::contains_dirty_lock ( ) const
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.

§ get_gap_mode()

okvl_mode::element_lock_mode okvl_mode::get_gap_mode ( ) const
inline

§ get_key_mode()

okvl_mode::element_lock_mode okvl_mode::get_key_mode ( ) const
inline

§ get_partition_mode()

okvl_mode::element_lock_mode okvl_mode::get_partition_mode ( part_id  partition) const
inline

§ is_compatible()

bool okvl_mode::is_compatible ( const okvl_mode requested,
const okvl_mode granted 
)
inlinestatic

Static function to tell whether the two modes are compatible.

§ is_compatible_element()

bool okvl_mode::is_compatible_element ( element_lock_mode  requested,
element_lock_mode  granted 
)
inlinestatic

Static function to check if two element lock modes are compatible.

§ is_compatible_grant()

bool okvl_mode::is_compatible_grant ( const okvl_mode granted) const
inline

Returns whether this requested mode can be allowed by the given granted mode.

§ is_compatible_request()

bool okvl_mode::is_compatible_request ( const okvl_mode requested) const
inline

Returns whether this granted mode allows the given requested mode.

§ is_empty()

bool okvl_mode::is_empty ( void  ) const
inline

Returns whether the lock modes are completely empty (all NULL modes).

§ is_implied_by()

bool okvl_mode::is_implied_by ( const okvl_mode superset) const
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.

§ is_implied_by_element()

bool okvl_mode::is_implied_by_element ( element_lock_mode  left,
element_lock_mode  right 
)
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".

§ is_keylock_empty()

bool okvl_mode::is_keylock_empty ( ) const
inline

Returns whether the key modes are completely empty, either key or its partitions.

§ is_keylock_partition_empty()

bool okvl_mode::is_keylock_partition_empty ( ) const
inline

Returns whether the key modes are either empty or key-mode only (S/X in key).

§ operator!=()

bool okvl_mode::operator!= ( const okvl_mode r) const
inline

§ operator=()

okvl_mode & okvl_mode::operator= ( const okvl_mode r)
inline

Copy constructor.

§ operator==()

bool okvl_mode::operator== ( const okvl_mode r) const
inline

operator overloads.

§ set_gap_mode()

void okvl_mode::set_gap_mode ( element_lock_mode  mode)
inline

Sets the gap mode.

§ set_key_mode()

void okvl_mode::set_key_mode ( element_lock_mode  mode)
inline

Sets the key mode.

§ set_partition_mode()

void okvl_mode::set_partition_mode ( part_id  partition,
element_lock_mode  mode 
)
inline

Sets an individual partition mode (and its intent mode on key).

Member Data Documentation

§ modes

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.


The documentation for this struct was generated from the following files: