libfoedus-core
FOEDUS Core Library
foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK > Class Template Reference

Implements McsAdaptorConcept over ThreadPimpl. More...

Detailed Description

template<typename RW_BLOCK>
class foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >

Implements McsAdaptorConcept over ThreadPimpl.

This object is instantiated for every MCS lock invocation in ThreadPimpl, but this object is essentially just the this pointer itself (pimpl_). The compiler will/should eliminate basically everything.

Definition at line 38 of file fwd.hpp.

#include <fwd.hpp>

Public Types

typedef RW_BLOCK ThisRwBlock
 

Public Member Functions

 ThreadPimplMcsAdaptor (ThreadPimpl *pimpl)
 
 ~ThreadPimplMcsAdaptor ()
 
xct::McsBlockIndex issue_new_block ()
 
void cancel_new_block (xct::McsBlockIndex the_block)
 
xct::McsBlockIndex get_cur_block () const
 
ThreadId get_my_id () const
 
ThreadGroupId get_my_numa_node () const
 
std::atomic< bool > * me_waiting ()
 
xct::McsWwBlockget_ww_my_block (xct::McsBlockIndex index)
 
RW_BLOCK * get_rw_my_block (xct::McsBlockIndex index)
 
std::atomic< bool > * other_waiting (ThreadId id)
 
xct::McsBlockIndex get_other_cur_block (ThreadId id)
 
xct::McsWwBlockget_ww_other_block (ThreadId id, xct::McsBlockIndex index)
 
RW_BLOCK * get_rw_other_block (ThreadId id, xct::McsBlockIndex index)
 
RW_BLOCK * dereference_rw_tail_block (uint32_t tail_int)
 
xct::McsRwExtendedBlockget_rw_other_async_block (ThreadId id, xct::McsRwLock *lock)
 
void add_rw_async_mapping (xct::McsRwLock *lock, xct::McsBlockIndex block_index)
 
void remove_rw_async_mapping (xct::McsRwLock *lock)
 

Member Typedef Documentation

template<typename RW_BLOCK>
typedef RW_BLOCK foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::ThisRwBlock

Definition at line 406 of file thread_pimpl.hpp.

Constructor & Destructor Documentation

template<typename RW_BLOCK>
foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::ThreadPimplMcsAdaptor ( ThreadPimpl pimpl)
inlineexplicit

Definition at line 408 of file thread_pimpl.hpp.

408 : pimpl_(pimpl) {}
template<typename RW_BLOCK>
foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::~ThreadPimplMcsAdaptor ( )
inline

Definition at line 409 of file thread_pimpl.hpp.

409 {}

Member Function Documentation

template<typename RW_BLOCK>
void foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::add_rw_async_mapping ( xct::McsRwLock lock,
xct::McsBlockIndex  block_index 
)
inline

Definition at line 481 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::xct::McsRwAsyncMapping::block_index_, foedus::thread::ThreadPimpl::control_block_, foedus::thread::ThreadPimpl::global_volatile_page_resolver_, foedus::xct::kNullUniversalLockId, foedus::xct::McsRwAsyncMapping::lock_id_, foedus::thread::ThreadControlBlock::mcs_rw_async_mapping_current_, foedus::thread::ThreadPimpl::mcs_rw_async_mappings_, and foedus::xct::rw_lock_to_universal_lock_id().

481  {
482  // TLS, no concurrency control needed
483  auto index = pimpl_->control_block_->mcs_rw_async_mapping_current_;
484  ASSERT_ND(index <= pimpl_->control_block_->mcs_block_current_);
486  ASSERT_ND(pimpl_->mcs_rw_async_mappings_[index].block_index_ == 0);
487  pimpl_->mcs_rw_async_mappings_[index].lock_id_ =
489  pimpl_->mcs_rw_async_mappings_[index].block_index_ = block_index;
491  }
memory::GlobalVolatilePageResolver global_volatile_page_resolver_
Page resolver to convert all page ID to page pointer.
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
Definition: xct_id.hpp:1231
uint32_t mcs_rw_async_mapping_current_
How many async mappings for extended RW lock we have so far.
xct::McsRwAsyncMapping * mcs_rw_async_mappings_
#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
UniversalLockId lock_id_
Definition: xct_id.hpp:874
const UniversalLockId kNullUniversalLockId
This never points to a valid lock, and also evaluates less than any vaild alocks. ...
Definition: xct_id.hpp:137
ThreadControlBlock * control_block_

Here is the call graph for this function:

template<typename RW_BLOCK>
void foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::cancel_new_block ( xct::McsBlockIndex  the_block)
inline

Definition at line 416 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::thread::ThreadPimpl::control_block_, and foedus::thread::ThreadControlBlock::mcs_block_current_.

416  {
417  ASSERT_ND(pimpl_->control_block_->mcs_block_current_ == the_block);
419  }
uint32_t mcs_block_current_
How many MCS blocks we allocated in this thread's current xct.
#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
ThreadControlBlock * control_block_
template<typename RW_BLOCK>
RW_BLOCK* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::dereference_rw_tail_block ( uint32_t  tail_int)
inline

Definition at line 464 of file thread_pimpl.hpp.

References foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_block(), foedus::xct::McsRwLock::get_tail_waiter(), foedus::xct::McsRwLock::get_tail_waiter_block(), and foedus::xct::McsRwLock::tail_.

464  {
465  xct::McsRwLock tail_tmp;
466  tail_tmp.tail_ = tail_int;
467  uint32_t tail_id = tail_tmp.get_tail_waiter();
468  uint32_t tail_block = tail_tmp.get_tail_waiter_block();
469  return get_rw_other_block(tail_id, tail_block);
470  }
RW_BLOCK * get_rw_other_block(ThreadId id, xct::McsBlockIndex index)

Here is the call graph for this function:

template<typename RW_BLOCK>
xct::McsBlockIndex foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_cur_block ( ) const
inline

Definition at line 420 of file thread_pimpl.hpp.

References foedus::thread::ThreadPimpl::control_block_, and foedus::thread::ThreadControlBlock::mcs_block_current_.

420 { return pimpl_->control_block_->mcs_block_current_; }
uint32_t mcs_block_current_
How many MCS blocks we allocated in this thread's current xct.
ThreadControlBlock * control_block_
template<typename RW_BLOCK>
ThreadId foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_my_id ( ) const
inline

Definition at line 421 of file thread_pimpl.hpp.

References foedus::thread::ThreadPimpl::id_.

Referenced by foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_async_block().

421 { return pimpl_->id_; }
const ThreadId id_
Unique ID of this thread.

Here is the caller graph for this function:

template<typename RW_BLOCK>
ThreadGroupId foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_my_numa_node ( ) const
inline

Definition at line 422 of file thread_pimpl.hpp.

References foedus::thread::ThreadPimpl::numa_node_.

422 { return pimpl_->numa_node_; }
const ThreadGroupId numa_node_
Node this thread belongs to.
template<typename RW_BLOCK>
xct::McsBlockIndex foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_other_cur_block ( ThreadId  id)
inline

Definition at line 445 of file thread_pimpl.hpp.

References foedus::thread::ThreadRef::get_control_block(), foedus::thread::ThreadPimpl::get_thread_ref(), and foedus::thread::ThreadControlBlock::mcs_block_current_.

445  {
446  ThreadRef other = pimpl_->get_thread_ref(id);
447  return other.get_control_block()->mcs_block_current_;
448  }
uint32_t mcs_block_current_
How many MCS blocks we allocated in this thread's current xct.
ThreadControlBlock * get_control_block() const
Definition: thread_ref.hpp:71
ThreadRef get_thread_ref(ThreadId id)

Here is the call graph for this function:

template<typename RW_BLOCK>
RW_BLOCK* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_my_block ( xct::McsBlockIndex  index)
inline

Definition at line 431 of file thread_pimpl.hpp.

References ASSERT_ND, and foedus::thread::ThreadPimpl::get_mcs_rw_my_blocks().

431  {
432  ASSERT_ND(index > 0);
433  ASSERT_ND(index < 0xFFFFU);
434  ASSERT_ND(index <= pimpl_->control_block_->mcs_block_current_);
435  RW_BLOCK* ret;
436  pimpl_->get_mcs_rw_my_blocks(&ret);
437  ret += index;
438  return ret;
439  }
void get_mcs_rw_my_blocks(xct::McsRwSimpleBlock **out)
#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:

template<typename RW_BLOCK>
xct::McsRwExtendedBlock* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_async_block ( ThreadId  id,
xct::McsRwLock lock 
)
inline

Definition at line 471 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::thread::ThreadRef::get_mcs_rw_async_mapping(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_my_id(), foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_block(), foedus::thread::ThreadPimpl::get_thread_ref(), foedus::thread::ThreadPimpl::global_volatile_page_resolver_, foedus::assorted::memory_fence_acquire(), and foedus::xct::rw_lock_to_universal_lock_id().

471  {
472  ASSERT_ND(id != get_my_id());
473  ThreadRef other = pimpl_->get_thread_ref(id);
476  auto* mapping = other.get_mcs_rw_async_mapping(lock_id);
477  ASSERT_ND(mapping);
478  ASSERT_ND(mapping->lock_id_ == lock_id);
479  return get_rw_other_block(id, mapping->block_index_);
480  }
memory::GlobalVolatilePageResolver global_volatile_page_resolver_
Page resolver to convert all page ID to page pointer.
RW_BLOCK * get_rw_other_block(ThreadId id, xct::McsBlockIndex index)
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
Definition: xct_id.hpp:1231
void memory_fence_acquire()
Equivalent to std::atomic_thread_fence(std::memory_order_acquire).
ThreadRef get_thread_ref(ThreadId id)
#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:

template<typename RW_BLOCK>
RW_BLOCK* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_block ( ThreadId  id,
xct::McsBlockIndex  index 
)
inline

Definition at line 454 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::thread::ThreadRef::get_control_block(), foedus::thread::ThreadRef::get_mcs_rw_blocks(), foedus::thread::ThreadPimpl::get_thread_ref(), and foedus::thread::ThreadControlBlock::mcs_block_current_.

Referenced by foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::dereference_rw_tail_block(), and foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_rw_other_async_block().

454  {
455  ASSERT_ND(index > 0);
456  ASSERT_ND(index < 0xFFFFU);
457  ThreadRef other = pimpl_->get_thread_ref(id);
458  RW_BLOCK* ret;
459  other.get_mcs_rw_blocks(&ret);
460  ASSERT_ND(index <= other.get_control_block()->mcs_block_current_);
461  ret += index;
462  return ret;
463  }
void get_mcs_rw_blocks(xct::McsRwSimpleBlock **out) const
Definition: thread_ref.hpp:68
ThreadRef get_thread_ref(ThreadId id)
#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:

template<typename RW_BLOCK>
xct::McsWwBlock* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_ww_my_block ( xct::McsBlockIndex  index)
inline

Definition at line 425 of file thread_pimpl.hpp.

References ASSERT_ND, and foedus::thread::ThreadPimpl::mcs_ww_blocks_.

425  {
426  ASSERT_ND(index > 0);
427  ASSERT_ND(index < 0xFFFFU);
428  ASSERT_ND(index <= pimpl_->control_block_->mcs_block_current_);
429  return pimpl_->mcs_ww_blocks_ + index;
430  }
xct::McsWwBlock * mcs_ww_blocks_
Pre-allocated MCS blocks.
#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
template<typename RW_BLOCK>
xct::McsWwBlock* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::get_ww_other_block ( ThreadId  id,
xct::McsBlockIndex  index 
)
inline

Definition at line 449 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::thread::ThreadRef::get_control_block(), foedus::thread::ThreadRef::get_mcs_ww_blocks(), foedus::thread::ThreadPimpl::get_thread_ref(), and foedus::thread::ThreadControlBlock::mcs_block_current_.

449  {
450  ThreadRef other = pimpl_->get_thread_ref(id);
451  ASSERT_ND(index <= other.get_control_block()->mcs_block_current_);
452  return other.get_mcs_ww_blocks() + index;
453  }
ThreadRef get_thread_ref(ThreadId id)
#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:

template<typename RW_BLOCK>
xct::McsBlockIndex foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::issue_new_block ( )
inline

Definition at line 411 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::thread::ThreadPimpl::control_block_, and foedus::thread::ThreadControlBlock::mcs_block_current_.

411  {
412  // if this assertion fires, probably we are retrying something too many times
413  ASSERT_ND(pimpl_->control_block_->mcs_block_current_ < 0xFFFFU);
414  return ++pimpl_->control_block_->mcs_block_current_;
415  }
uint32_t mcs_block_current_
How many MCS blocks we allocated in this thread's current xct.
#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
ThreadControlBlock * control_block_
template<typename RW_BLOCK>
std::atomic<bool>* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::me_waiting ( )
inline

Definition at line 423 of file thread_pimpl.hpp.

References foedus::thread::ThreadPimpl::control_block_, and foedus::thread::ThreadControlBlock::mcs_waiting_.

423 { return &pimpl_->control_block_->mcs_waiting_; }
std::atomic< bool > mcs_waiting_
Whether this thread is waiting for some MCS lock.
ThreadControlBlock * control_block_
template<typename RW_BLOCK>
std::atomic<bool>* foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::other_waiting ( ThreadId  id)
inline

Definition at line 441 of file thread_pimpl.hpp.

References foedus::thread::ThreadRef::get_control_block(), foedus::thread::ThreadPimpl::get_thread_ref(), and foedus::thread::ThreadControlBlock::mcs_waiting_.

441  {
442  ThreadRef other = pimpl_->get_thread_ref(id);
443  return &(other.get_control_block()->mcs_waiting_);
444  }
ThreadRef get_thread_ref(ThreadId id)

Here is the call graph for this function:

template<typename RW_BLOCK>
void foedus::thread::ThreadPimplMcsAdaptor< RW_BLOCK >::remove_rw_async_mapping ( xct::McsRwLock lock)
inline

Definition at line 492 of file thread_pimpl.hpp.

References ASSERT_ND, foedus::xct::McsRwAsyncMapping::block_index_, foedus::thread::ThreadPimpl::control_block_, foedus::thread::ThreadPimpl::global_volatile_page_resolver_, foedus::xct::kNullUniversalLockId, foedus::xct::McsRwAsyncMapping::lock_id_, foedus::thread::ThreadControlBlock::mcs_rw_async_mapping_current_, foedus::thread::ThreadPimpl::mcs_rw_async_mappings_, and foedus::xct::rw_lock_to_universal_lock_id().

492  {
493  xct::UniversalLockId lock_id =
496  for (uint32_t i = 0; i < pimpl_->control_block_->mcs_rw_async_mapping_current_; ++i) {
497  if (pimpl_->mcs_rw_async_mappings_[i].lock_id_ == lock_id) {
500  pimpl_->mcs_rw_async_mappings_[i].block_index_= 0;
501  return;
502  }
503  }
504  ASSERT_ND(false);
505  }
memory::GlobalVolatilePageResolver global_volatile_page_resolver_
Page resolver to convert all page ID to page pointer.
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
Definition: xct_id.hpp:1231
uintptr_t UniversalLockId
Universally ordered identifier of each lock.
Definition: xct_id.hpp:134
uint32_t mcs_rw_async_mapping_current_
How many async mappings for extended RW lock we have so far.
xct::McsRwAsyncMapping * mcs_rw_async_mappings_
#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
UniversalLockId lock_id_
Definition: xct_id.hpp:874
const UniversalLockId kNullUniversalLockId
This never points to a valid lock, and also evaluates less than any vaild alocks. ...
Definition: xct_id.hpp:137
ThreadControlBlock * control_block_

Here is the call graph for this function:


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