libfoedus-core
FOEDUS Core Library
foedus::memory::AlignedMemorySlice Struct Referencefinal

A slice of foedus::memory::AlignedMemory. More...

Detailed Description

A slice of foedus::memory::AlignedMemory.

This class is used to split a single (often large) foedus::memory::AlignedMemory to be used by multiple consumers. Such use has a performance advantage because many smaller memory pieces are consolidated to one large piece from the viewpoint of OS. In particular, it might be that allocating a consolidated memory triggers transparent hugepage while allocating individual memory does not.

This object is a POD.

Definition at line 210 of file aligned_memory.hpp.

#include <aligned_memory.hpp>

Collaboration diagram for foedus::memory::AlignedMemorySlice:

Public Member Functions

 AlignedMemorySlice ()
 Empty constructor. More...
 
 AlignedMemorySlice (AlignedMemory *memory)
 A dummy slice that covers the memory entirely. More...
 
 AlignedMemorySlice (AlignedMemory *memory, uint64_t offset, uint64_t count)
 A slice that covers the specified region of the memory. More...
 
 AlignedMemorySlice (const AlignedMemorySlice &slice, uint64_t offset, uint64_t count)
 A slice that covers the specified region of another slice. More...
 
void clear ()
 
bool is_valid () const
 
uint64_t get_size () const
 
void * get_block () const
 

Public Attributes

AlignedMemorymemory_
 The wrapped memory. More...
 
uint64_t offset_
 Byte offset of this slice in memory_. More...
 
uint64_t count_
 Byte count of this slice in memory_. More...
 

Friends

std::ostream & operator<< (std::ostream &o, const AlignedMemorySlice &v)
 

Constructor & Destructor Documentation

foedus::memory::AlignedMemorySlice::AlignedMemorySlice ( )
inline

Empty constructor.

Definition at line 212 of file aligned_memory.hpp.

212 : memory_(CXX11_NULLPTR), offset_(0), count_(0) {}
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
uint64_t count_
Byte count of this slice in memory_.
AlignedMemory * memory_
The wrapped memory.
uint64_t offset_
Byte offset of this slice in memory_.
foedus::memory::AlignedMemorySlice::AlignedMemorySlice ( AlignedMemory memory)
inlineexplicit

A dummy slice that covers the memory entirely.

Definition at line 215 of file aligned_memory.hpp.

216  : memory_(memory), offset_(0), count_(memory->get_size()) {}
uint64_t count_
Byte count of this slice in memory_.
AlignedMemory * memory_
The wrapped memory.
uint64_t offset_
Byte offset of this slice in memory_.
foedus::memory::AlignedMemorySlice::AlignedMemorySlice ( AlignedMemory memory,
uint64_t  offset,
uint64_t  count 
)
inline

A slice that covers the specified region of the memory.

Definition at line 219 of file aligned_memory.hpp.

References ASSERT_ND, and foedus::memory::AlignedMemory::get_size().

220  : memory_(memory), offset_(offset), count_(count) {
221  ASSERT_ND(memory->get_size() >= count + offset);
222  }
uint64_t count_
Byte count of this slice in memory_.
AlignedMemory * memory_
The wrapped memory.
uint64_t offset_
Byte offset of this slice in memory_.
#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:

foedus::memory::AlignedMemorySlice::AlignedMemorySlice ( const AlignedMemorySlice slice,
uint64_t  offset,
uint64_t  count 
)
inline

A slice that covers the specified region of another slice.

Definition at line 225 of file aligned_memory.hpp.

References ASSERT_ND, and get_size().

226  : memory_(slice.memory_), offset_(slice.offset_ + offset), count_(count) {
227  ASSERT_ND(slice.get_size() >= count + offset);
228  }
uint64_t count_
Byte count of this slice in memory_.
AlignedMemory * memory_
The wrapped memory.
uint64_t offset_
Byte offset of this slice in memory_.
#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:

Member Function Documentation

void foedus::memory::AlignedMemorySlice::clear ( )
inline

Definition at line 232 of file aligned_memory.hpp.

References CXX11_NULLPTR, and memory_.

Referenced by foedus::memory::NumaCoreMemory::uninitialize_once().

232 { memory_ = CXX11_NULLPTR; }
#define CXX11_NULLPTR
Used in public headers in place of "nullptr" of C++11.
Definition: cxx11.hpp:132
AlignedMemory * memory_
The wrapped memory.

Here is the caller graph for this function:

void* foedus::memory::AlignedMemorySlice::get_block ( ) const
inline

Definition at line 235 of file aligned_memory.hpp.

References foedus::memory::AlignedMemory::get_block(), memory_, and offset_.

Referenced by foedus::log::ThreadLogBuffer::initialize_once(), foedus::fs::DirectIoFile::read(), and foedus::fs::DirectIoFile::write().

235 { return reinterpret_cast<char*>(memory_->get_block()) + offset_; }
AlignedMemory * memory_
The wrapped memory.
void * get_block() const
Returns the memory block.
uint64_t offset_
Byte offset of this slice in memory_.

Here is the call graph for this function:

Here is the caller graph for this function:

uint64_t foedus::memory::AlignedMemorySlice::get_size ( ) const
inline

Definition at line 234 of file aligned_memory.hpp.

References count_.

Referenced by AlignedMemorySlice(), and foedus::log::ThreadLogBuffer::initialize_once().

234 { return count_; }
uint64_t count_
Byte count of this slice in memory_.

Here is the caller graph for this function:

bool foedus::memory::AlignedMemorySlice::is_valid ( ) const
inline

Definition at line 233 of file aligned_memory.hpp.

References memory_.

Referenced by foedus::fs::DirectIoFile::write().

233 { return memory_; }
AlignedMemory * memory_
The wrapped memory.

Here is the caller graph for this function:

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  o,
const AlignedMemorySlice v 
)
friend

Definition at line 282 of file aligned_memory.cpp.

282  {
283  o << "<AlignedMemorySlice>";
284  o << "<offset>" << v.offset_ << "</offset>";
285  o << "<count>" << v.count_ << "</count>";
286  if (v.memory_) {
287  o << *v.memory_;
288  }
289  o << "</AlignedMemorySlice>";
290  return o;
291 }

Member Data Documentation

uint64_t foedus::memory::AlignedMemorySlice::count_

Byte count of this slice in memory_.

Definition at line 242 of file aligned_memory.hpp.

Referenced by get_size(), foedus::memory::operator<<(), foedus::fs::DirectIoFile::read(), and foedus::fs::DirectIoFile::write().

AlignedMemory* foedus::memory::AlignedMemorySlice::memory_

The wrapped memory.

This object is just a view. It doesn't release the block.

Definition at line 238 of file aligned_memory.hpp.

Referenced by clear(), get_block(), is_valid(), foedus::memory::operator<<(), foedus::fs::DirectIoFile::read(), and foedus::fs::DirectIoFile::write().

uint64_t foedus::memory::AlignedMemorySlice::offset_

Byte offset of this slice in memory_.

Definition at line 240 of file aligned_memory.hpp.

Referenced by get_block(), and foedus::memory::operator<<().


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