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

An iterator over CurrentLockList to find entries along with sorted write-set. More...

Detailed Description

An iterator over CurrentLockList to find entries along with sorted write-set.

This is used from precommit_xct_lock() to iterate over CurrentLockList. Separated as an iterator object by itself for readability and testability.

Note
This object itself is thread-private. No concurrency control needed.

Definition at line 243 of file xct_manager_pimpl.hpp.

#include <xct_manager_pimpl.hpp>

Collaboration diagram for foedus::xct::CurrentLockListIteratorForWriteSet:

Public Member Functions

 CurrentLockListIteratorForWriteSet (const WriteXctAccess *write_set, const CurrentLockList *cll, uint32_t write_set_size)
 
void next_writes ()
 Look for next record's write-set(s). More...
 
bool is_valid () const
 

Public Attributes

const WriteXctAccess *const write_set_
 
const CurrentLockList *const cll_
 
const uint32_t write_set_size_
 
uint32_t write_cur_pos_
 inclusive beginning of write-sets of the current record in write-set. More...
 
uint32_t write_next_pos_
 exclusive end of write-sets of the current record in write-set. More...
 
LockListPosition cll_pos_
 CLL entry that corresponds to the current record in write-set. More...
 

Constructor & Destructor Documentation

foedus::xct::CurrentLockListIteratorForWriteSet::CurrentLockListIteratorForWriteSet ( const WriteXctAccess write_set,
const CurrentLockList cll,
uint32_t  write_set_size 
)
inline
Precondition
write_set must be sorted and CLL must contain all entries for write-sets. In other words, you must call precommit_xct_sort_access() and batch_insert_write_placeholders() beforehand.

Definition at line 277 of file xct_manager_pimpl.hpp.

References foedus::xct::CurrentLockList::assert_sorted(), cll_, cll_pos_, foedus::xct::kLockListPositionInvalid, next_writes(), write_cur_pos_, and write_next_pos_.

281  : write_set_(write_set),
282  cll_(cll),
283  write_set_size_(write_set_size) {
284  write_cur_pos_ = 0;
285  write_next_pos_ = 0;
287  cll_->assert_sorted();
288 
289  next_writes(); // set to initial record.
290 }
uint32_t write_next_pos_
exclusive end of write-sets of the current record in write-set.
const LockListPosition kLockListPositionInvalid
Definition: xct_id.hpp:149
void next_writes()
Look for next record's write-set(s).
uint32_t write_cur_pos_
inclusive beginning of write-sets of the current record in write-set.
LockListPosition cll_pos_
CLL entry that corresponds to the current record in write-set.
void assert_sorted() const __attribute__((always_inline))

Here is the call graph for this function:

Member Function Documentation

bool foedus::xct::CurrentLockListIteratorForWriteSet::is_valid ( ) const
inline

Definition at line 259 of file xct_manager_pimpl.hpp.

References write_cur_pos_, and write_next_pos_.

Referenced by foedus::xct::XctManagerPimpl::precommit_xct_lock().

259 { return write_cur_pos_ < write_next_pos_; }
uint32_t write_next_pos_
exclusive end of write-sets of the current record in write-set.
uint32_t write_cur_pos_
inclusive beginning of write-sets of the current record in write-set.

Here is the caller graph for this function:

void foedus::xct::CurrentLockListIteratorForWriteSet::next_writes ( )
inline

Look for next record's write-set(s).

Precondition
is_valid(). otherwise undefined behavior

Definition at line 292 of file xct_manager_pimpl.hpp.

References ASSERT_ND, cll_, cll_pos_, foedus::xct::CurrentLockList::get_entry(), foedus::xct::RecordXctAccess::owner_lock_id_, foedus::xct::LockEntry::universal_lock_id_, write_cur_pos_, write_next_pos_, write_set_, and write_set_size_.

Referenced by CurrentLockListIteratorForWriteSet().

292  {
294  ++cll_pos_;
296  return;
297  }
298  const WriteXctAccess* write = write_set_ + write_cur_pos_;
299  const UniversalLockId write_id = write->owner_lock_id_;
300 
301  // CLL must contain all entries in write-set. We are reading in-order.
302  // So, we must find a valid CLL entry that is == write_id
303  const LockEntry* l = cll_->get_entry(cll_pos_);
304  while (l->universal_lock_id_ < write_id) {
305  ASSERT_ND(cll_pos_ < cll_->get_last_active_entry());
306  ++cll_pos_;
307  l = cll_->get_entry(cll_pos_);
308  }
309 
310  ASSERT_ND(l->universal_lock_id_ == write_id);
312  while (true) {
313  ++write_next_pos_;
315  break;
316  }
317  const WriteXctAccess* next_write = write_set_ + write_next_pos_;
318  const UniversalLockId next_write_id = next_write->owner_lock_id_;
319  ASSERT_ND(write_id <= next_write_id);
320  if (write_id < next_write_id) {
321  break;
322  }
323  }
324 }
uint32_t write_next_pos_
exclusive end of write-sets of the current record in write-set.
uintptr_t UniversalLockId
Universally ordered identifier of each lock.
Definition: xct_id.hpp:134
uint32_t write_cur_pos_
inclusive beginning of write-sets of the current record in write-set.
LockEntry * get_entry(LockListPosition pos)
LockListPosition cll_pos_
CLL entry that corresponds to the current record in write-set.
#define ASSERT_ND(x)
A warning-free wrapper macro of assert() that has no performance effect in release mode even when 'x'...
Definition: assert_nd.hpp:72

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

const CurrentLockList* const foedus::xct::CurrentLockListIteratorForWriteSet::cll_

Definition at line 262 of file xct_manager_pimpl.hpp.

Referenced by CurrentLockListIteratorForWriteSet(), and next_writes().

LockListPosition foedus::xct::CurrentLockListIteratorForWriteSet::cll_pos_

CLL entry that corresponds to the current record in write-set.

Definition at line 274 of file xct_manager_pimpl.hpp.

Referenced by CurrentLockListIteratorForWriteSet(), and next_writes().

uint32_t foedus::xct::CurrentLockListIteratorForWriteSet::write_cur_pos_

inclusive beginning of write-sets of the current record in write-set.

Definition at line 268 of file xct_manager_pimpl.hpp.

Referenced by CurrentLockListIteratorForWriteSet(), is_valid(), and next_writes().

uint32_t foedus::xct::CurrentLockListIteratorForWriteSet::write_next_pos_

exclusive end of write-sets of the current record in write-set.

Definition at line 272 of file xct_manager_pimpl.hpp.

Referenced by CurrentLockListIteratorForWriteSet(), is_valid(), and next_writes().

const WriteXctAccess* const foedus::xct::CurrentLockListIteratorForWriteSet::write_set_

Definition at line 261 of file xct_manager_pimpl.hpp.

Referenced by next_writes().

const uint32_t foedus::xct::CurrentLockListIteratorForWriteSet::write_set_size_

Definition at line 263 of file xct_manager_pimpl.hpp.

Referenced by next_writes().


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