mutable
A Database System for Research and Fast Prototyping
Loading...
Searching...
No Matches
Public Member Functions | Private Member Functions | Private Attributes | Friends
m::memory::Memory Struct Reference

Represents a mapping created by a memory::Allocator. More...

#include <memory.hpp>

Collaboration diagram for m::memory::Memory:
[legend]

Public Member Functions

 Memory ()
 
 Memory (void *addr, std::size_t size)
 
 ~Memory ()
 
 Memory (const Memory &)=delete
 
 Memory (Memory &&other)
 
Memoryoperator= (Memory &&other)
 
Allocatorallocator () const
 Returns a reference to the allocator that created this allocation.
 
void * addr () const
 Returns a pointer to the beginning of the virtual address space where this allocation is mapped to.
 
std::size_t size () const
 Returns the size in bytes of this allocation.
 
std::size_t offset () const
 Returns the offset in bytes of this allocation within its allocator.
 
template<typename T >
T as ()
 Returns a pointer to the beginning of the virtual address space where this allocation is mapped to, converted to type T.
 
template<typename T >
const T as () const
 Returns a pointer to the beginning of the virtual address space where this allocation is mapped to, converted to type T.
 
void map (std::size_t size, std::size_t offset_src, const AddressSpace &vm, std::size_t offset_dst) const
 Map size bytes starting at offset_src into the address space of vm at offset offset_dst.
 
void dump (std::ostream &out) const
 
void dump () const
 

Private Member Functions

 Memory (Allocator &allocator, void *addr, std::size_t size, std::size_t offset)
 

Private Attributes

Allocatorallocator_ = nullptr
 the allocator that created this memory allocation
 
void * addr_ = nullptr
 pointer to the virtual address space where this allocation is mapped to
 
std::size_t size_ = 0
 the size of this allocation
 
std::size_t offset_ = 0
 the offset of this allocation within its allocator
 

Friends

struct Allocator
 
void swap (Memory &first, Memory &second)
 

Detailed Description

Represents a mapping created by a memory::Allocator.

The class holds all information on the mapping, i.e. a reference to the allocator that created the mapping, a pointer to the beginning of the virtual address range that was mapped to, the offset within the allocator, and the size of the allocation.

Definition at line 77 of file memory.hpp.

Constructor & Destructor Documentation

◆ Memory() [1/5]

Memory::Memory ( Allocator allocator,
void *  addr,
std::size_t  size,
std::size_t  offset 
)
private

Definition at line 78 of file memory.cpp.

◆ Memory() [2/5]

m::memory::Memory::Memory ( )
inline

Definition at line 98 of file memory.hpp.

◆ Memory() [3/5]

m::memory::Memory::Memory ( void *  addr,
std::size_t  size 
)
inline

Definition at line 99 of file memory.hpp.

◆ ~Memory()

m::memory::Memory::~Memory ( )
inline

Definition at line 100 of file memory.hpp.

References m::allocator< Actual >::deallocate().

◆ Memory() [4/5]

m::memory::Memory::Memory ( const Memory )
delete

◆ Memory() [5/5]

m::memory::Memory::Memory ( Memory &&  other)
inline

Definition at line 102 of file memory.hpp.

References m::swap().

Member Function Documentation

◆ addr()

void * m::memory::Memory::addr ( ) const
inline

Returns a pointer to the beginning of the virtual address space where this allocation is mapped to.

Definition at line 109 of file memory.hpp.

Referenced by dump(), m::PaxStore::dump(), m::RowStore::dump(), map(), and m::ColumnStore::memory().

◆ allocator()

Allocator & m::memory::Memory::allocator ( ) const
inline

Returns a reference to the allocator that created this allocation.

Definition at line 107 of file memory.hpp.

References M_insist.

Referenced by dump(), and map().

◆ as() [1/2]

template<typename T >
T m::memory::Memory::as ( )
inline

Returns a pointer to the beginning of the virtual address space where this allocation is mapped to, converted to type T.

Definition at line 118 of file memory.hpp.

References m::T().

Referenced by m::RowStore::at().

◆ as() [2/2]

template<typename T >
const T m::memory::Memory::as ( ) const
inline

Returns a pointer to the beginning of the virtual address space where this allocation is mapped to, converted to type T.

Definition at line 122 of file memory.hpp.

References m::T().

◆ dump() [1/2]

void Memory::dump ( ) const

Definition at line 112 of file memory.cpp.

References dump().

Referenced by dump().

◆ dump() [2/2]

M_LCOV_EXCL_START void Memory::dump ( std::ostream &  out) const

Definition at line 107 of file memory.cpp.

References addr(), allocator(), m::memory::Allocator::fd(), offset(), and size().

◆ map()

void Memory::map ( std::size_t  size,
std::size_t  offset_src,
const AddressSpace vm,
std::size_t  offset_dst 
) const

Map size bytes starting at offset_src into the address space of vm at offset offset_dst.


Definition at line 85 of file memory.cpp.

References addr(), allocator(), m::memory::AddressSpace::as(), m::Is_Page_Aligned(), M_insist, offset(), m::memory::AddressSpace::size(), and size().

Referenced by m::WasmEngine::WasmContext::map_table(), and m::wasm::Module::Memory().

◆ offset()

std::size_t m::memory::Memory::offset ( ) const
inline

Returns the offset in bytes of this allocation within its allocator.

Definition at line 113 of file memory.hpp.

Referenced by dump(), and map().

◆ operator=()

Memory & m::memory::Memory::operator= ( Memory &&  other)
inline

Definition at line 104 of file memory.hpp.

References m::swap().

◆ size()

std::size_t m::memory::Memory::size ( ) const
inline

Returns the size in bytes of this allocation.

Definition at line 111 of file memory.hpp.

Referenced by m::ColumnStore::ColumnStore(), dump(), and map().

Friends And Related Function Documentation

◆ Allocator

friend struct Allocator
friend

Definition at line 79 of file memory.hpp.

◆ swap

void swap ( Memory first,
Memory second 
)
friend

Definition at line 90 of file memory.hpp.

Field Documentation

◆ addr_

void* m::memory::Memory::addr_ = nullptr
private

pointer to the virtual address space where this allocation is mapped to

Definition at line 83 of file memory.hpp.

◆ allocator_

Allocator* m::memory::Memory::allocator_ = nullptr
private

the allocator that created this memory allocation

Definition at line 82 of file memory.hpp.

◆ offset_

std::size_t m::memory::Memory::offset_ = 0
private

the offset of this allocation within its allocator

Definition at line 85 of file memory.hpp.

◆ size_

std::size_t m::memory::Memory::size_ = 0
private

the size of this allocation

Definition at line 84 of file memory.hpp.


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