libfoedus-core
FOEDUS Core Library
foedus::xct::LockEntry Struct Reference

An entry in CLL and RLL, representing a lock that is taken or will be taken. More...

Detailed Description

An entry in CLL and RLL, representing a lock that is taken or will be taken.

This is a POD, and guaranteed to be init-ed/reset-ed by memzero and copied via memcpy. We initially had a separate entry object for RLL and CLL, but they were always the same. We might differentiate them later, but for now reuse the same code.

Definition at line 120 of file retrospective_lock_list.hpp.

#include <retrospective_lock_list.hpp>

Collaboration diagram for foedus::xct::LockEntry:

Classes

struct  LessThan
 for std::binary_search() etc without creating the object More...
 

Public Member Functions

void set (UniversalLockId id, RwLockableXctId *lock, LockMode preferred_mode, LockMode taken_mode)
 
bool is_locked () const
 
bool is_enough () const
 
bool operator< (const LockEntry &rhs) const
 

Public Attributes

UniversalLockId universal_lock_id_
 Used to order locks in canonical order. More...
 
RwLockableXctIdlock_
 Virtual address of the lock. More...
 
LockMode preferred_mode_
 Whick lock mode we should take according to RLL. More...
 
LockMode taken_mode_
 Whick lock mode we have taken during the current run (of course initially kNoLock) More...
 
McsBlockIndex mcs_block_
 0 means the lock not taken. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const LockEntry &v)
 Debugging. More...
 

Member Function Documentation

bool foedus::xct::LockEntry::is_enough ( ) const
inline

Definition at line 163 of file retrospective_lock_list.hpp.

References preferred_mode_.

Referenced by foedus::xct::CurrentLockList::cancel_async_single_lock(), foedus::xct::Xct::on_record_read_take_locks_if_needed(), foedus::xct::CurrentLockList::retry_async_single_lock(), foedus::xct::CurrentLockList::try_async_single_lock(), and foedus::xct::CurrentLockList::try_or_acquire_single_lock().

163 { return taken_mode_ >= preferred_mode_; }
LockMode preferred_mode_
Whick lock mode we should take according to RLL.
LockMode taken_mode_
Whick lock mode we have taken during the current run (of course initially kNoLock) ...

Here is the caller graph for this function:

bool foedus::xct::LockEntry::is_locked ( ) const
inline

Definition at line 162 of file retrospective_lock_list.hpp.

References foedus::xct::kNoLock.

Referenced by foedus::xct::CurrentLockList::retry_async_single_lock(), and foedus::xct::CurrentLockList::try_or_acquire_single_lock().

162 { return taken_mode_ != kNoLock; }
taken_mode_: Not taken the lock yet.
Definition: xct_id.hpp:100
LockMode taken_mode_
Whick lock mode we have taken during the current run (of course initially kNoLock) ...

Here is the caller graph for this function:

bool foedus::xct::LockEntry::operator< ( const LockEntry rhs) const
inline

Definition at line 165 of file retrospective_lock_list.hpp.

References universal_lock_id_.

165  {
166  return universal_lock_id_ < rhs.universal_lock_id_;
167  }
UniversalLockId universal_lock_id_
Used to order locks in canonical order.
void foedus::xct::LockEntry::set ( UniversalLockId  id,
RwLockableXctId lock,
LockMode  preferred_mode,
LockMode  taken_mode 
)
inline

Definition at line 150 of file retrospective_lock_list.hpp.

Referenced by foedus::xct::CurrentLockList::batch_insert_write_placeholders(), foedus::xct::RetrospectiveLockList::construct(), and foedus::xct::CurrentLockList::get_or_add_entry().

154  {
155  universal_lock_id_ = id;
156  lock_ = lock;
157  preferred_mode_ = preferred_mode;
158  taken_mode_ = taken_mode;
159  mcs_block_ = 0;
160  }
UniversalLockId universal_lock_id_
Used to order locks in canonical order.
McsBlockIndex mcs_block_
0 means the lock not taken.
LockMode preferred_mode_
Whick lock mode we should take according to RLL.
LockMode taken_mode_
Whick lock mode we have taken during the current run (of course initially kNoLock) ...
RwLockableXctId * lock_
Virtual address of the lock.

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const LockEntry v 
)
friend

Debugging.

Definition at line 118 of file retrospective_lock_list.cpp.

118  {
119  o << "<LockEntry>"
120  << "<LockId>" << v.universal_lock_id_ << "</LockId>"
121  << "<PreferredMode>" << v.preferred_mode_ << "</PreferredMode>"
122  << "<TakenMode>" << v.taken_mode_ << "</TakenMode>";
123  if (v.lock_) {
124  o << *(v.lock_);
125  } else {
126  o << "<Lock>nullptr</Lock>";
127  }
128  o << "</LockEntry>";
129  return o;
130 }

Member Data Documentation


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