SIRIUS 7.5.0
Electronic structure library and applications
Public Member Functions | Private Attributes | List of all members
sirius::sddk::memory_pool Class Reference

#include <memory.hpp>

Public Member Functions

 memory_pool (memory_t M__)
 Constructor. More...
 
template<typename T >
T * allocate (size_t num_elements__)
 Return a pointer to a memory block for n elements of type T. More...
 
void free (void *ptr__)
 Delete a pointer and add its memory back to the pool. More...
 
template<typename T >
std::unique_ptr< T, memory_t_deleter_baseget_unique_ptr (size_t n__)
 Return a unique pointer to the allocated memory. More...
 
void reset ()
 Free all the allocated blocks. umpire does not support this. More...
 
void clear ()
 shrink the memory pool and release all memory. More...
 
memory_t memory_type () const
 Return the type of memory this pool is managing. More...
 
size_t total_size () const
 Return the total capacity of the memory pool. More...
 
size_t free_size () const
 Get the total free size of the memory pool. More...
 
size_t num_blocks () const
 Get the number of free memory blocks. More...
 

Private Attributes

memory_t M_
 Type of memory that is handeled by this pool. More...
 

Detailed Description

This class stores list of allocated memory blocks. Each of the blocks can be divided into subblocks. When subblock is deallocated it is merged with previous or next free subblock in the memory block. If this was the last subblock in the block of memory, the (now) free block of memory is merged with the neighbours (if any are available).

Definition at line 355 of file memory.hpp.

Constructor & Destructor Documentation

◆ memory_pool()

sirius::sddk::memory_pool::memory_pool ( memory_t  M__)
inline

Constructor.

Definition at line 369 of file memory.hpp.

Member Function Documentation

◆ allocate()

template<typename T >
T * sirius::sddk::memory_pool::allocate ( size_t  num_elements__)
inline

Return a pointer to a memory block for n elements of type T.

Definition at line 427 of file memory.hpp.

◆ free()

void sirius::sddk::memory_pool::free ( void *  ptr__)
inline

Delete a pointer and add its memory back to the pool.

Definition at line 441 of file memory.hpp.

◆ get_unique_ptr()

template<typename T >
std::unique_ptr< T, memory_t_deleter_base > sirius::sddk::memory_pool::get_unique_ptr ( size_t  n__)
inline

Return a unique pointer to the allocated memory.

Definition at line 456 of file memory.hpp.

◆ reset()

void sirius::sddk::memory_pool::reset ( )
inline

Free all the allocated blocks. umpire does not support this.

All pointers and smart pointers, allocated by the pool are invalidated.

Definition at line 467 of file memory.hpp.

◆ clear()

void sirius::sddk::memory_pool::clear ( )
inline

shrink the memory pool and release all memory.

Definition at line 472 of file memory.hpp.

◆ memory_type()

memory_t sirius::sddk::memory_pool::memory_type ( ) const
inline

Return the type of memory this pool is managing.

Definition at line 483 of file memory.hpp.

◆ total_size()

size_t sirius::sddk::memory_pool::total_size ( ) const
inline

Return the total capacity of the memory pool.

Definition at line 489 of file memory.hpp.

◆ free_size()

size_t sirius::sddk::memory_pool::free_size ( ) const
inline

Get the total free size of the memory pool.

Definition at line 500 of file memory.hpp.

◆ num_blocks()

size_t sirius::sddk::memory_pool::num_blocks ( ) const
inline

Get the number of free memory blocks.

Definition at line 512 of file memory.hpp.

Member Data Documentation

◆ M_

memory_t sirius::sddk::memory_pool::M_
private

Type of memory that is handeled by this pool.

Definition at line 359 of file memory.hpp.


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