libfoedus-core
FOEDUS Core Library
foedus::xct::McsMockContext< RW_BLOCK > Struct Template Reference

Analogous to the entire engine. More...

Detailed Description

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

Analogous to the entire engine.

Note
completely header-only

Definition at line 247 of file xct_mcs_adapter_impl.hpp.

#include <xct_mcs_adapter_impl.hpp>

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

Public Member Functions

void init (storage::StorageId dummy_storage_id, uint32_t nodes, uint32_t threads_per_node, uint32_t max_block_count, uint32_t max_lock_count)
 
RwLockableXctIdget_rw_lock_address (uint16_t node_id, uint64_t lock_index)
 
McsWwLockget_ww_lock_address (uint16_t node_id, uint64_t lock_index)
 

Public Attributes

uint32_t max_block_count_
 
uint32_t max_lock_count_
 
uint32_t pages_per_node_
 
std::vector< McsMockNode< RW_BLOCK > > nodes_
 
memory::GlobalVolatilePageResolver page_memory_resolver_
 All locks managed by this objects are placed in these memory regions. More...
 

Member Function Documentation

template<typename RW_BLOCK>
RwLockableXctId* foedus::xct::McsMockContext< RW_BLOCK >::get_rw_lock_address ( uint16_t  node_id,
uint64_t  lock_index 
)
inline

Definition at line 269 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::kMcsMockDataPageLocksPerPage, foedus::xct::McsMockContext< RW_BLOCK >::max_lock_count_, foedus::xct::McsMockContext< RW_BLOCK >::nodes_, foedus::xct::McsMockContext< RW_BLOCK >::pages_per_node_, and foedus::xct::McsMockDataPage::tid_.

269  {
270  ASSERT_ND(lock_index < max_lock_count_);
271  ASSERT_ND(node_id < nodes_.size());
272  const uint64_t page_index = lock_index / kMcsMockDataPageLocksPerPage + 1U;
273  const uint64_t lock_in_page_index = lock_index % kMcsMockDataPageLocksPerPage;;
274  ASSERT_ND(page_index < pages_per_node_);
275  McsMockDataPage* page = nodes_[node_id].pages_ + page_index;
276  return page->tid_ + lock_in_page_index;
277  }
constexpr uint32_t kMcsMockDataPageLocksPerPage
std::vector< McsMockNode< RW_BLOCK > > nodes_
#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>
McsWwLock* foedus::xct::McsMockContext< RW_BLOCK >::get_ww_lock_address ( uint16_t  node_id,
uint64_t  lock_index 
)
inline

Definition at line 278 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::xct::kMcsMockDataPageLocksPerPage, foedus::xct::McsMockContext< RW_BLOCK >::max_lock_count_, foedus::xct::McsMockContext< RW_BLOCK >::nodes_, foedus::xct::McsMockContext< RW_BLOCK >::pages_per_node_, and foedus::xct::McsMockDataPage::ww_.

278  {
279  ASSERT_ND(lock_index < max_lock_count_);
280  ASSERT_ND(node_id < nodes_.size());
281  const uint64_t page_index = lock_index / kMcsMockDataPageLocksPerPage + 1U;
282  const uint64_t lock_in_page_index = lock_index % kMcsMockDataPageLocksPerPage;;
283  ASSERT_ND(page_index < pages_per_node_);
284  McsMockDataPage* page = nodes_[node_id].pages_ + page_index;
285  return page->ww_ + lock_in_page_index;
286  }
constexpr uint32_t kMcsMockDataPageLocksPerPage
std::vector< McsMockNode< RW_BLOCK > > nodes_
#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>
void foedus::xct::McsMockContext< RW_BLOCK >::init ( storage::StorageId  dummy_storage_id,
uint32_t  nodes,
uint32_t  threads_per_node,
uint32_t  max_block_count,
uint32_t  max_lock_count 
)
inline

Definition at line 248 of file xct_mcs_adapter_impl.hpp.

References ASSERT_ND, foedus::memory::GlobalVolatilePageResolver::bases_, foedus::memory::GlobalVolatilePageResolver::begin_, foedus::memory::GlobalVolatilePageResolver::end_, foedus::xct::kMcsMockDataPageLocksPerPage, foedus::xct::McsMockContext< RW_BLOCK >::max_block_count_, foedus::xct::McsMockContext< RW_BLOCK >::max_lock_count_, foedus::xct::McsMockContext< RW_BLOCK >::nodes_, foedus::memory::GlobalVolatilePageResolver::numa_node_count_, foedus::xct::McsMockContext< RW_BLOCK >::page_memory_resolver_, and foedus::xct::McsMockContext< RW_BLOCK >::pages_per_node_.

253  {
254  max_block_count_ = max_block_count;
255  max_lock_count_ = max_lock_count;
256  // + 1U for index-0 (which is not used), and +1U for ceiling
258  nodes_.resize(nodes);
263  for (uint32_t n = 0; n < nodes; ++n) {
264  nodes_[n].init(dummy_storage_id, n, threads_per_node, max_block_count, pages_per_node_);
265  page_memory_resolver_.bases_[n] = reinterpret_cast<storage::Page*>(nodes_[n].pages_);
266  }
267  }
memory::GlobalVolatilePageResolver page_memory_resolver_
All locks managed by this objects are placed in these memory regions.
uint16_t numa_node_count_
number of NUMA nodes in this engine.
PagePoolOffset begin_
where a valid page entry starts.
constexpr uint32_t kMcsMockDataPageLocksPerPage
PagePoolOffset end_
where a valid page entry ends.
std::vector< McsMockNode< RW_BLOCK > > nodes_
#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
Base bases_[kMaxNumaNode]
base address to calculate from/to offset.

Member Data Documentation

template<typename RW_BLOCK>
uint32_t foedus::xct::McsMockContext< RW_BLOCK >::max_block_count_
template<typename RW_BLOCK>
memory::GlobalVolatilePageResolver foedus::xct::McsMockContext< RW_BLOCK >::page_memory_resolver_

All locks managed by this objects are placed in these memory regions.

Unlike the real engine, these are not shared-memory, but the page resolver logic doesn't care whether it's shared-memory or not, so it's fine.

Definition at line 297 of file xct_mcs_adapter_impl.hpp.

Referenced by foedus::xct::McsMockContext< RW_BLOCK >::init().


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