SIRIUS 7.5.0
Electronic structure library and applications
|
#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_base > | get_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... | |
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.
|
inline |
Constructor.
Definition at line 369 of file memory.hpp.
|
inline |
Return a pointer to a memory block for n elements of type T.
Definition at line 427 of file memory.hpp.
|
inline |
Delete a pointer and add its memory back to the pool.
Definition at line 441 of file memory.hpp.
|
inline |
Return a unique pointer to the allocated memory.
Definition at line 456 of file memory.hpp.
|
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.
|
inline |
shrink the memory pool and release all memory.
Definition at line 472 of file memory.hpp.
|
inline |
Return the type of memory this pool is managing.
Definition at line 483 of file memory.hpp.
|
inline |
Return the total capacity of the memory pool.
Definition at line 489 of file memory.hpp.
|
inline |
Get the total free size of the memory pool.
Definition at line 500 of file memory.hpp.
|
inline |
Get the number of free memory blocks.
Definition at line 512 of file memory.hpp.
|
private |
Type of memory that is handeled by this pool.
Definition at line 359 of file memory.hpp.