libfoedus-core
FOEDUS Core Library
foedus::xct::McsMockAdaptor< RW_BLOCK > Class Template Reference

Implements McsAdaptorConcept. More...

Detailed Description

template<typename RW_BLOCK>
class foedus::xct::McsMockAdaptor< RW_BLOCK >

Implements McsAdaptorConcept.

Note
completely header-only

Definition at line 305 of file xct_mcs_adapter_impl.hpp.

#include <xct_mcs_adapter_impl.hpp>

Public Types

typedef RW_BLOCK ThisRwBlock
 

Public Member Functions

 McsMockAdaptor (thread::ThreadId id, McsMockContext< RW_BLOCK > *context)
 
 ~McsMockAdaptor ()
 
McsBlockIndex issue_new_block ()
 
void cancel_new_block (McsBlockIndex the_block)
 
McsBlockIndex get_cur_block () const
 
thread::ThreadId get_my_id () const
 
thread::ThreadGroupId get_my_numa_node () const
 
std::atomic< bool > * me_waiting ()
 
McsWwBlockget_ww_my_block (McsBlockIndex index)
 
RW_BLOCK * get_rw_my_block (McsBlockIndex index)
 
McsMockThread< RW_BLOCK > * get_other_thread (thread::ThreadId id)
 
std::atomic< bool > * other_waiting (thread::ThreadId id)
 
McsBlockIndex get_other_cur_block (thread::ThreadId id)
 
McsWwBlockget_ww_other_block (thread::ThreadId id, McsBlockIndex index)
 
RW_BLOCK * get_rw_other_block (thread::ThreadId id, McsBlockIndex index)
 
RW_BLOCK * get_rw_other_block (uint32_t block_int)
 
RW_BLOCK * dereference_rw_tail_block (uint32_t tail_int)
 
McsRwExtendedBlockget_rw_other_async_block (thread::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::xct::McsMockAdaptor< RW_BLOCK >::ThisRwBlock

Definition at line 307 of file xct_mcs_adapter_impl.hpp.

Constructor & Destructor Documentation

template<typename RW_BLOCK >
foedus::xct::McsMockAdaptor< RW_BLOCK >::McsMockAdaptor ( thread::ThreadId  id,
McsMockContext< RW_BLOCK > *  context 
)
inline

Definition at line 309 of file xct_mcs_adapter_impl.hpp.

310  : id_(id),
311  numa_node_(thread::decompose_numa_node(id)),
312  local_ordinal_(thread::decompose_numa_local_ordinal(id)),
313  context_(context),
314  me_(context->nodes_[numa_node_].threads_.data() + local_ordinal_) {}
ThreadLocalOrdinal decompose_numa_local_ordinal(ThreadId global_id)
Extracts local ordinal from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:139
ThreadGroupId decompose_numa_node(ThreadId global_id)
Extracts NUMA node ID from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:131
template<typename RW_BLOCK >
foedus::xct::McsMockAdaptor< RW_BLOCK >::~McsMockAdaptor ( )
inline

Definition at line 315 of file xct_mcs_adapter_impl.hpp.

315 {}

Member Function Documentation

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

Definition at line 385 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::kNullUniversalLockId, and foedus::xct::rw_lock_to_universal_lock_id().

385  {
386  ASSERT_ND(lock);
387  ASSERT_ND(block_index);
388  auto ulockid = xct::rw_lock_to_universal_lock_id(context_->page_memory_resolver_, lock);
389 #ifndef NDEBUG
390  for (uint32_t i = 0; i < me_->mcs_rw_async_mapping_current_; ++i) {
391  if (me_->mcs_rw_async_mappings_[i].lock_id_ == ulockid) {
392  ASSERT_ND(false);
393  }
394  }
395 #endif
396  // TLS, no concurrency control needed
397  auto index = me_->mcs_rw_async_mapping_current_++;
398  ASSERT_ND(me_->mcs_rw_async_mappings_[index].lock_id_ == kNullUniversalLockId);
399  me_->mcs_rw_async_mappings_[index].lock_id_ = ulockid;
400  me_->mcs_rw_async_mappings_[index].block_index_ = block_index;
401  }
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
Definition: xct_id.hpp:1231
#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
const UniversalLockId kNullUniversalLockId
This never points to a valid lock, and also evaluates less than any vaild alocks. ...
Definition: xct_id.hpp:137

Here is the call graph for this function:

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

Definition at line 322 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND.

322  {
323  ASSERT_ND(me_->mcs_block_current_ == the_block);
324  --me_->mcs_block_current_;
325  }
#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 >
RW_BLOCK* foedus::xct::McsMockAdaptor< RW_BLOCK >::dereference_rw_tail_block ( uint32_t  tail_int)
inline

Definition at line 371 of file xct_mcs_adapter_impl.hpp.

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

371  {
372  McsRwLock tail_tmp;
373  tail_tmp.tail_ = tail_int;
374  uint32_t tail_id = tail_tmp.get_tail_waiter();
375  uint32_t tail_block = tail_tmp.get_tail_waiter_block();
376  return get_rw_other_block(tail_id, tail_block);
377  }
RW_BLOCK * get_rw_other_block(thread::ThreadId id, McsBlockIndex index)

Here is the call graph for this function:

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

Definition at line 326 of file xct_mcs_adapter_impl.hpp.

326 { return me_->mcs_block_current_; }
template<typename RW_BLOCK >
thread::ThreadId foedus::xct::McsMockAdaptor< RW_BLOCK >::get_my_id ( ) const
inline

Definition at line 327 of file xct_mcs_adapter_impl.hpp.

327 { return id_; }
template<typename RW_BLOCK >
thread::ThreadGroupId foedus::xct::McsMockAdaptor< RW_BLOCK >::get_my_numa_node ( ) const
inline

Definition at line 328 of file xct_mcs_adapter_impl.hpp.

328 { return numa_node_; }
template<typename RW_BLOCK >
McsBlockIndex foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_cur_block ( thread::ThreadId  id)
inline

Definition at line 351 of file xct_mcs_adapter_impl.hpp.

References foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), and foedus::xct::McsMockThread< RW_BLOCK >::mcs_block_current_.

351  {
352  McsMockThread<RW_BLOCK>* other = get_other_thread(id);
353  return other->mcs_block_current_;
354  }
McsMockThread< RW_BLOCK > * get_other_thread(thread::ThreadId id)

Here is the call graph for this function:

template<typename RW_BLOCK >
McsMockThread<RW_BLOCK>* foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread ( thread::ThreadId  id)
inline

Definition at line 340 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::thread::decompose_numa_local_ordinal(), and foedus::thread::decompose_numa_node().

Referenced by foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_cur_block(), foedus::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_async_block(), foedus::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_block(), foedus::xct::McsMockAdaptor< RW_BLOCK >::get_ww_other_block(), and foedus::xct::McsMockAdaptor< RW_BLOCK >::other_waiting().

340  {
342  ASSERT_ND(node < context_->nodes_.size());
344  ASSERT_ND(ordinal < context_->nodes_[node].threads_.size());
345  return context_->nodes_[node].threads_.data() + ordinal;
346  }
uint8_t ThreadLocalOrdinal
Typedef for a local ID of Thread (core), which is NOT unique across NUMA nodes.
Definition: thread_id.hpp:58
ThreadLocalOrdinal decompose_numa_local_ordinal(ThreadId global_id)
Extracts local ordinal from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:139
ThreadGroupId decompose_numa_node(ThreadId global_id)
Extracts NUMA node ID from the given globally unique ID of Thread (core).
Definition: thread_id.hpp:131
#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
uint8_t ThreadGroupId
Typedef for an ID of ThreadGroup (NUMA node).
Definition: thread_id.hpp:38

Here is the call graph for this function:

Here is the caller graph for this function:

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

Definition at line 335 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND.

335  {
336  ASSERT_ND(index <= me_->mcs_block_current_);
337  return me_->mcs_rw_blocks_.data() + index;
338  }
#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 >
McsRwExtendedBlock* foedus::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_async_block ( thread::ThreadId  id,
xct::McsRwLock lock 
)
inline

Definition at line 378 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::McsMockThread< RW_BLOCK >::get_mcs_rw_async_block_index(), foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), and foedus::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_block().

378  {
379  McsMockThread<RW_BLOCK>* other = get_other_thread(id);
380  McsBlockIndex block
381  = other->get_mcs_rw_async_block_index(context_->page_memory_resolver_, lock);
382  ASSERT_ND(block);
383  return get_rw_other_block(id, block);
384  }
McsMockThread< RW_BLOCK > * get_other_thread(thread::ThreadId id)
uint32_t McsBlockIndex
Index in thread-local MCS block.
Definition: xct_id.hpp:153
RW_BLOCK * get_rw_other_block(thread::ThreadId id, McsBlockIndex index)
#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::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_block ( thread::ThreadId  id,
McsBlockIndex  index 
)
inline

Definition at line 360 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), and foedus::xct::McsMockThread< RW_BLOCK >::mcs_rw_blocks_.

Referenced by foedus::xct::McsMockAdaptor< RW_BLOCK >::dereference_rw_tail_block(), and foedus::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_async_block().

360  {
361  McsMockThread<RW_BLOCK>* other = get_other_thread(id);
362  ASSERT_ND(index <= other->mcs_block_current_);
363  return other->mcs_rw_blocks_.data() + index;
364  }
McsMockThread< RW_BLOCK > * get_other_thread(thread::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 >
RW_BLOCK* foedus::xct::McsMockAdaptor< RW_BLOCK >::get_rw_other_block ( uint32_t  block_int)
inline

Definition at line 365 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), and foedus::xct::McsMockThread< RW_BLOCK >::mcs_rw_blocks_.

365  {
366  McsMockThread<RW_BLOCK>* other = get_other_thread(block_int >> 16);
367  McsBlockIndex index = block_int & 0xFFFFU;
368  ASSERT_ND(index <= other->mcs_block_current_);
369  return other->mcs_rw_blocks_.data() + index;
370  }
McsMockThread< RW_BLOCK > * get_other_thread(thread::ThreadId id)
uint32_t McsBlockIndex
Index in thread-local MCS block.
Definition: xct_id.hpp:153
#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 >
McsWwBlock* foedus::xct::McsMockAdaptor< RW_BLOCK >::get_ww_my_block ( McsBlockIndex  index)
inline

Definition at line 331 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND.

331  {
332  ASSERT_ND(index <= me_->mcs_block_current_);
333  return me_->mcs_ww_blocks_.data() + index;
334  }
#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 >
McsWwBlock* foedus::xct::McsMockAdaptor< RW_BLOCK >::get_ww_other_block ( thread::ThreadId  id,
McsBlockIndex  index 
)
inline

Definition at line 355 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), and foedus::xct::McsMockThread< RW_BLOCK >::mcs_ww_blocks_.

355  {
356  McsMockThread<RW_BLOCK>* other = get_other_thread(id);
357  ASSERT_ND(index <= other->mcs_block_current_);
358  return other->mcs_ww_blocks_.data() + index;
359  }
McsMockThread< RW_BLOCK > * get_other_thread(thread::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 >
McsBlockIndex foedus::xct::McsMockAdaptor< RW_BLOCK >::issue_new_block ( )
inline

Definition at line 317 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND.

317  {
318  // if this assertion fires, probably we are retrying something too many times
319  ASSERT_ND(me_->mcs_block_current_ < 0xFFFFU);
320  return ++me_->mcs_block_current_;
321  }
#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 >
std::atomic<bool>* foedus::xct::McsMockAdaptor< RW_BLOCK >::me_waiting ( )
inline

Definition at line 329 of file xct_mcs_adapter_impl.hpp.

329 { return &me_->mcs_waiting_; }
template<typename RW_BLOCK >
std::atomic<bool>* foedus::xct::McsMockAdaptor< RW_BLOCK >::other_waiting ( thread::ThreadId  id)
inline

Definition at line 347 of file xct_mcs_adapter_impl.hpp.

References foedus::xct::McsMockAdaptor< RW_BLOCK >::get_other_thread(), and foedus::xct::McsMockThread< RW_BLOCK >::mcs_waiting_.

347  {
348  McsMockThread<RW_BLOCK>* other = get_other_thread(id);
349  return &(other->mcs_waiting_);
350  }
McsMockThread< RW_BLOCK > * get_other_thread(thread::ThreadId id)

Here is the call graph for this function:

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

Definition at line 402 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::kNullUniversalLockId, and foedus::xct::rw_lock_to_universal_lock_id().

402  {
403  ASSERT_ND(me_->mcs_rw_async_mapping_current_);
404  auto lock_id = xct::rw_lock_to_universal_lock_id(context_->page_memory_resolver_, lock);
405  for (uint32_t i = 0; i < me_->mcs_rw_async_mapping_current_; ++i) {
406  if (me_->mcs_rw_async_mappings_[i].lock_id_ == lock_id) {
407  me_->mcs_rw_async_mappings_[i].lock_id_ = kNullUniversalLockId;
408  --me_->mcs_rw_async_mapping_current_;
409  return;
410  }
411  }
412  ASSERT_ND(false);
413  }
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
Definition: xct_id.hpp:1231
#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
const UniversalLockId kNullUniversalLockId
This never points to a valid lock, and also evaluates less than any vaild alocks. ...
Definition: xct_id.hpp:137

Here is the call graph for this function:


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