KratosMultiphysics
KRATOS Multiphysics (Kratos) is a framework for building parallel, multi-disciplinary simulation software, aiming at modularity, extensibility, and high performance. Kratos is written in C++, and counts with an extensive Python interface.
Static Public Attributes | List of all members
Kratos::ThreadFixedSizeMemoryPool Class Reference

ThreadFixedSizeMemoryPool holds chunks belong to a certain thread and operate over them. More...

#include <thread_fixed_size_memory_pool.h>

Collaboration diagram for Kratos::ThreadFixedSizeMemoryPool:

Public Types

Type Definitions
using SizeType = Chunk::SizeType
 
using ChunkList = std::list< Chunk * >
 

Public Member Functions

Life Cycle
 ThreadFixedSizeMemoryPool ()=delete
 Default constructor is deleted. More...
 
 ThreadFixedSizeMemoryPool (ThreadFixedSizeMemoryPool const &rOther)=delete
 Copy constructor is deleted. More...
 
 ThreadFixedSizeMemoryPool (ThreadFixedSizeMemoryPool &&rOther)=default
 Move constructor to be used in STL containers. More...
 
 ThreadFixedSizeMemoryPool (std::size_t BlockSizeInBytes, SizeType ChunkSize, std::size_t ThreadNumber)
 The constructor to be called. More...
 
virtual ~ThreadFixedSizeMemoryPool ()
 Destructor. More...
 
Operators
ThreadFixedSizeMemoryPooloperator= (ThreadFixedSizeMemoryPool const &rOther)=delete
 Assignment operator is deleted. More...
 
Access
std::size_t GetNumberOfChunks () const
 
std::size_t GetNumberOfAvailableChunks () const
 
std::size_t GetNumberOfReleasedChunks () const
 
Inquiry
bool HasAvailableChunk ()
 
Input and output
std::string Info () const
 Turn back information as a string. More...
 
void PrintInfo (std::ostream &rOStream) const
 Print information about this object. More...
 
void PrintData (std::ostream &rOStream) const
 Print object's data. More...
 

Static Public Attributes

static constexpr SizeType MaximumEmptyChunksToKeep = 4
 
static constexpr SizeType MaximumPointersToKeep = 1024
 

Operations

void * Allocate ()
 This function does not throw and returns zero if cannot allocate. More...
 
bool Deallocate (void *pPointerToRelease)
 
void Release ()
 
SizeType ChunkSize () const
 
std::size_t MemoryUsed () const
 
std::size_t MemoryOverhead () const
 
void lock ()
 
void unlock ()
 

Detailed Description

ThreadFixedSizeMemoryPool holds chunks belong to a certain thread and operate over them.

The memory management of Kratos is implemented based on the design given in Modern C++ Design by A. Alexandrescu and ThreadFixedSizeMemoryPool is the second layer of it "Called FixedAllocator" holding chunks. This class is the owner of the chunks of this thread and the only one who can allocate in them. The rest of the threads would only deallocate objects.

Member Typedef Documentation

◆ ChunkList

◆ SizeType

Constructor & Destructor Documentation

◆ ThreadFixedSizeMemoryPool() [1/4]

Kratos::ThreadFixedSizeMemoryPool::ThreadFixedSizeMemoryPool ( )
delete

Default constructor is deleted.

◆ ThreadFixedSizeMemoryPool() [2/4]

Kratos::ThreadFixedSizeMemoryPool::ThreadFixedSizeMemoryPool ( ThreadFixedSizeMemoryPool const &  rOther)
delete

Copy constructor is deleted.

◆ ThreadFixedSizeMemoryPool() [3/4]

Kratos::ThreadFixedSizeMemoryPool::ThreadFixedSizeMemoryPool ( ThreadFixedSizeMemoryPool &&  rOther)
default

Move constructor to be used in STL containers.

◆ ThreadFixedSizeMemoryPool() [4/4]

Kratos::ThreadFixedSizeMemoryPool::ThreadFixedSizeMemoryPool ( std::size_t  BlockSizeInBytes,
SizeType  ChunkSize,
std::size_t  ThreadNumber 
)
inline

The constructor to be called.

◆ ~ThreadFixedSizeMemoryPool()

virtual Kratos::ThreadFixedSizeMemoryPool::~ThreadFixedSizeMemoryPool ( )
inlinevirtual

Destructor.

Member Function Documentation

◆ Allocate()

void* Kratos::ThreadFixedSizeMemoryPool::Allocate ( )
inline

This function does not throw and returns zero if cannot allocate.

◆ ChunkSize()

SizeType Kratos::ThreadFixedSizeMemoryPool::ChunkSize ( ) const
inline

◆ Deallocate()

bool Kratos::ThreadFixedSizeMemoryPool::Deallocate ( void *  pPointerToRelease)
inline

◆ GetNumberOfAvailableChunks()

std::size_t Kratos::ThreadFixedSizeMemoryPool::GetNumberOfAvailableChunks ( ) const
inline

◆ GetNumberOfChunks()

std::size_t Kratos::ThreadFixedSizeMemoryPool::GetNumberOfChunks ( ) const
inline

◆ GetNumberOfReleasedChunks()

std::size_t Kratos::ThreadFixedSizeMemoryPool::GetNumberOfReleasedChunks ( ) const
inline

◆ HasAvailableChunk()

bool Kratos::ThreadFixedSizeMemoryPool::HasAvailableChunk ( )
inline

◆ Info()

std::string Kratos::ThreadFixedSizeMemoryPool::Info ( ) const
inline

Turn back information as a string.

◆ lock()

void Kratos::ThreadFixedSizeMemoryPool::lock ( )
inline

◆ MemoryOverhead()

std::size_t Kratos::ThreadFixedSizeMemoryPool::MemoryOverhead ( ) const
inline

◆ MemoryUsed()

std::size_t Kratos::ThreadFixedSizeMemoryPool::MemoryUsed ( ) const
inline

◆ operator=()

ThreadFixedSizeMemoryPool& Kratos::ThreadFixedSizeMemoryPool::operator= ( ThreadFixedSizeMemoryPool const &  rOther)
delete

Assignment operator is deleted.

◆ PrintData()

void Kratos::ThreadFixedSizeMemoryPool::PrintData ( std::ostream &  rOStream) const
inline

Print object's data.

◆ PrintInfo()

void Kratos::ThreadFixedSizeMemoryPool::PrintInfo ( std::ostream &  rOStream) const
inline

Print information about this object.

◆ Release()

void Kratos::ThreadFixedSizeMemoryPool::Release ( )
inline

◆ unlock()

void Kratos::ThreadFixedSizeMemoryPool::unlock ( )
inline

Member Data Documentation

◆ MaximumEmptyChunksToKeep

constexpr SizeType Kratos::ThreadFixedSizeMemoryPool::MaximumEmptyChunksToKeep = 4
staticconstexpr

◆ MaximumPointersToKeep

constexpr SizeType Kratos::ThreadFixedSizeMemoryPool::MaximumPointersToKeep = 1024
staticconstexpr

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