libfoedus-core
FOEDUS Core Library
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
foedus::xct::McsMockThread< RW_BLOCK > Struct Template Reference

A dummy implementation that provides McsAdaptorConcept for testing. More...

Detailed Description

template<typename RW_BLOCK>
struct foedus::xct::McsMockThread< RW_BLOCK >

A dummy implementation that provides McsAdaptorConcept for testing.

A testcase shares an instance of this object and creates below to test locking logics easily without any other FOEDUS engine pieces. These mock objects are only for testing, thus no performance optimization at all.

You might feel it weird to have classes for testing here, but we need to define them here to allow explicit instantiation of templated functions receiving these objects within xct_mcs_impl.cpp. Otherwise we have to define, not just declare, the templated funcs in hpp.

Note
completely header-only

Definition at line 129 of file xct_mcs_adapter_impl.hpp.

#include <xct_mcs_adapter_impl.hpp>

Collaboration diagram for foedus::xct::McsMockThread< RW_BLOCK >:

Public Member Functions

 McsMockThread ()=default
 
 McsMockThread (McsMockThread &&rhs)
 
void init (uint32_t max_block_count)
 
xct::McsBlockIndex get_mcs_rw_async_block_index (const memory::GlobalVolatilePageResolver &resolver, xct::McsRwLock *lock)
 

Public Attributes

std::vector< McsWwBlockmcs_ww_blocks_
 
std::vector< RW_BLOCK > mcs_rw_blocks_
 
std::vector< xct::McsRwAsyncMappingmcs_rw_async_mappings_
 
uint32_t mcs_rw_async_mapping_current_
 
uint32_t mcs_block_current_
 
std::atomic< bool > mcs_waiting_
 

Constructor & Destructor Documentation

template<typename RW_BLOCK>
foedus::xct::McsMockThread< RW_BLOCK >::McsMockThread ( )
default
template<typename RW_BLOCK>
foedus::xct::McsMockThread< RW_BLOCK >::McsMockThread ( McsMockThread< RW_BLOCK > &&  rhs)
inline

Definition at line 131 of file xct_mcs_adapter_impl.hpp.

References foedus::xct::McsMockThread< RW_BLOCK >::mcs_block_current_, foedus::xct::McsMockThread< RW_BLOCK >::mcs_rw_async_mappings_, foedus::xct::McsMockThread< RW_BLOCK >::mcs_rw_blocks_, foedus::xct::McsMockThread< RW_BLOCK >::mcs_waiting_, and foedus::xct::McsMockThread< RW_BLOCK >::mcs_ww_blocks_.

131  {
132  // heh, std::vector::resize() demands a move constructor.
133  mcs_ww_blocks_ = std::move(rhs.mcs_ww_blocks_);
134  mcs_rw_blocks_ = std::move(rhs.mcs_rw_blocks_);
135  mcs_rw_async_mappings_ = std::move(rhs.mcs_rw_async_mappings_);
136  mcs_block_current_ = rhs.mcs_block_current_;
137  mcs_waiting_.store(rhs.mcs_waiting_.load()); // mainly due to this guy, this is NOT a move
138  }
std::vector< RW_BLOCK > mcs_rw_blocks_
std::vector< McsWwBlock > mcs_ww_blocks_
std::vector< xct::McsRwAsyncMapping > mcs_rw_async_mappings_

Member Function Documentation

template<typename RW_BLOCK>
xct::McsBlockIndex foedus::xct::McsMockThread< RW_BLOCK >::get_mcs_rw_async_block_index ( const memory::GlobalVolatilePageResolver resolver,
xct::McsRwLock lock 
)
inline

Definition at line 147 of file xct_mcs_adapter_impl.hpp.

References foedus::xct::McsMockThread< RW_BLOCK >::mcs_rw_async_mappings_, and foedus::xct::rw_lock_to_universal_lock_id().

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

149  {
150  auto ulockid = xct::rw_lock_to_universal_lock_id(resolver, lock);
151  for (auto &m : mcs_rw_async_mappings_) {
152  if (m.lock_id_ == ulockid) {
153  return m.block_index_;
154  }
155  }
156  return 0;
157  }
UniversalLockId rw_lock_to_universal_lock_id(const memory::GlobalVolatilePageResolver &resolver, McsRwLock *lock)
Definition: xct_id.hpp:1231
std::vector< xct::McsRwAsyncMapping > mcs_rw_async_mappings_

Here is the call graph for this function:

Here is the caller graph for this function:

template<typename RW_BLOCK>
void foedus::xct::McsMockThread< RW_BLOCK >::init ( uint32_t  max_block_count)
inline

Member Data Documentation

template<typename RW_BLOCK>
uint32_t foedus::xct::McsMockThread< RW_BLOCK >::mcs_rw_async_mapping_current_

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