Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
Référence du modèle de la classe MemoryPoolAllocator< BaseAllocator >

Default memory allocator used by the parser and DOM. Plus de détails...

#include <arcane/utils/internal/json/rapidjson/allocators.h>

+ Graphe de collaboration de MemoryPoolAllocator< BaseAllocator >:

Classes

struct  ChunkHeader
 Chunk header for perpending to each chunk. Plus de détails...
 

Fonctions membres publiques

 MemoryPoolAllocator (size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
 Constructor with chunkSize.
 
 MemoryPoolAllocator (void *buffer, size_t size, size_t chunkSize=kDefaultChunkCapacity, BaseAllocator *baseAllocator=0)
 Constructor with user-supplied buffer.
 
 ~MemoryPoolAllocator ()
 Destructor.
 
void Clear ()
 Deallocates all memory chunks, excluding the user-supplied buffer.
 
size_t Capacity () const
 Computes the total capacity of allocated memory chunks.
 
size_t Size () const
 Computes the memory blocks allocated.
 
void * Malloc (size_t size)
 Allocates a memory block. (concept Allocator)
 
void * Realloc (void *originalPtr, size_t originalSize, size_t newSize)
 Resizes a memory block (concept Allocator)
 

Fonctions membres publiques statiques

static void Free (void *ptr)
 Frees a memory block (concept Allocator)
 

Attributs publics statiques

static const bool kNeedFree = false
 Tell users that no need to call Free() with this allocator. (concept Allocator)
 

Fonctions membres privées

 MemoryPoolAllocator (const MemoryPoolAllocator &rhs)
 Copy constructor is not permitted.
 
MemoryPoolAllocatoroperator= (const MemoryPoolAllocator &rhs)
 Copy assignment operator is not permitted.
 
bool AddChunk (size_t capacity)
 Creates a new chunk.
 

Attributs privés

ChunkHeaderchunkHead_
 Head of the chunk linked-list. Only the head chunk serves allocation.
 
size_t chunk_capacity_
 The minimum capacity of chunk when they are allocated.
 
void * userBuffer_
 User supplied buffer.
 
BaseAllocator * baseAllocator_
 base allocator for allocating memory chunks.
 
BaseAllocator * ownBaseAllocator_
 base allocator created by this object.
 

Attributs privés statiques

static const int kDefaultChunkCapacity = RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY
 Default chunk capacity.
 

Description détaillée

template<typename BaseAllocator = CrtAllocator>
class MemoryPoolAllocator< BaseAllocator >

Default memory allocator used by the parser and DOM.

This allocator allocate memory blocks from pre-allocated memory chunks.

It does not free memory blocks. And Realloc() only allocate new memory.

The memory chunks are allocated by BaseAllocator, which is CrtAllocator by default.

User may also supply a buffer as the first chunk.

If the user-buffer is full then additional chunks are allocated by BaseAllocator.

The user-buffer is not deallocated by this allocator.

Paramètres du template
BaseAllocatorthe allocator type for allocating memory chunks. Default is CrtAllocator.
Note
implements Allocator concept

Définition à la ligne 116 du fichier allocators.h.

Documentation des constructeurs et destructeur

◆ MemoryPoolAllocator() [1/2]

template<typename BaseAllocator = CrtAllocator>
MemoryPoolAllocator< BaseAllocator >::MemoryPoolAllocator ( size_t  chunkSize = kDefaultChunkCapacity,
BaseAllocator *  baseAllocator = 0 
)
inline

Constructor with chunkSize.

Paramètres
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.

Définition à la ligne 124 du fichier allocators.h.

◆ MemoryPoolAllocator() [2/2]

template<typename BaseAllocator = CrtAllocator>
MemoryPoolAllocator< BaseAllocator >::MemoryPoolAllocator ( void *  buffer,
size_t  size,
size_t  chunkSize = kDefaultChunkCapacity,
BaseAllocator *  baseAllocator = 0 
)
inline

Constructor with user-supplied buffer.

The user buffer will be used firstly. When it is full, memory pool allocates new chunk with chunk size.

The user buffer will not be deallocated when this allocator is destructed.

Paramètres
bufferUser supplied buffer.
sizeSize of the buffer in bytes. It must at least larger than sizeof(ChunkHeader).
chunkSizeThe size of memory chunk. The default is kDefaultChunkSize.
baseAllocatorThe allocator for allocating memory chunks.

Définition à la ligne 139 du fichier allocators.h.

Références MemoryPoolAllocator< BaseAllocator >::ChunkHeader::capacity, MemoryPoolAllocator< BaseAllocator >::chunkHead_, MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next, RAPIDJSON_ASSERT, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::size.

◆ ~MemoryPoolAllocator()

template<typename BaseAllocator = CrtAllocator>
MemoryPoolAllocator< BaseAllocator >::~MemoryPoolAllocator ( )
inline

Destructor.

This deallocates all memory chunks, excluding the user-supplied buffer.

Définition à la ligne 153 du fichier allocators.h.

Références MemoryPoolAllocator< BaseAllocator >::Clear(), MemoryPoolAllocator< BaseAllocator >::ownBaseAllocator_, et RAPIDJSON_DELETE.

Documentation des fonctions membres

◆ AddChunk()

template<typename BaseAllocator = CrtAllocator>
bool MemoryPoolAllocator< BaseAllocator >::AddChunk ( size_t  capacity)
inlineprivate

Creates a new chunk.

Paramètres
capacityCapacity of the chunk in bytes.
Renvoie
true if success.

Définition à la ligne 251 du fichier allocators.h.

Références MemoryPoolAllocator< BaseAllocator >::baseAllocator_, MemoryPoolAllocator< BaseAllocator >::chunkHead_, MemoryPoolAllocator< BaseAllocator >::ownBaseAllocator_, RAPIDJSON_ALIGN, et RAPIDJSON_NEW.

Référencé par MemoryPoolAllocator< BaseAllocator >::Malloc().

◆ Capacity()

template<typename BaseAllocator = CrtAllocator>
size_t MemoryPoolAllocator< BaseAllocator >::Capacity ( ) const
inline

Computes the total capacity of allocated memory chunks.

Renvoie
total capacity in bytes.

Définition à la ligne 172 du fichier allocators.h.

Références MemoryPoolAllocator< BaseAllocator >::chunkHead_, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next.

◆ Clear()

template<typename BaseAllocator = CrtAllocator>
void MemoryPoolAllocator< BaseAllocator >::Clear ( )
inline

◆ Free()

template<typename BaseAllocator = CrtAllocator>
static void MemoryPoolAllocator< BaseAllocator >::Free ( void *  ptr)
inlinestatic

Frees a memory block (concept Allocator)

Définition à la ligne 239 du fichier allocators.h.

◆ Malloc()

◆ Realloc()

template<typename BaseAllocator = CrtAllocator>
void * MemoryPoolAllocator< BaseAllocator >::Realloc ( void *  originalPtr,
size_t  originalSize,
size_t  newSize 
)
inline

◆ Size()

template<typename BaseAllocator = CrtAllocator>
size_t MemoryPoolAllocator< BaseAllocator >::Size ( ) const
inline

Computes the memory blocks allocated.

Renvoie
total used bytes.

Définition à la ligne 182 du fichier allocators.h.

Références MemoryPoolAllocator< BaseAllocator >::chunkHead_, et MemoryPoolAllocator< BaseAllocator >::ChunkHeader::next.

Documentation des données membres

◆ baseAllocator_

template<typename BaseAllocator = CrtAllocator>
BaseAllocator* MemoryPoolAllocator< BaseAllocator >::baseAllocator_
private

base allocator for allocating memory chunks.

Définition à la ligne 279 du fichier allocators.h.

Référencé par MemoryPoolAllocator< BaseAllocator >::AddChunk(), et MemoryPoolAllocator< BaseAllocator >::Clear().

◆ chunk_capacity_

template<typename BaseAllocator = CrtAllocator>
size_t MemoryPoolAllocator< BaseAllocator >::chunk_capacity_
private

The minimum capacity of chunk when they are allocated.

Définition à la ligne 277 du fichier allocators.h.

Référencé par MemoryPoolAllocator< BaseAllocator >::Malloc().

◆ chunkHead_

◆ kDefaultChunkCapacity

template<typename BaseAllocator = CrtAllocator>
const int MemoryPoolAllocator< BaseAllocator >::kDefaultChunkCapacity = RAPIDJSON_ALLOCATOR_DEFAULT_CHUNK_CAPACITY
staticprivate

Default chunk capacity.

Définition à la ligne 265 du fichier allocators.h.

◆ kNeedFree

template<typename BaseAllocator = CrtAllocator>
const bool MemoryPoolAllocator< BaseAllocator >::kNeedFree = false
static

Tell users that no need to call Free() with this allocator. (concept Allocator)

Définition à la ligne 118 du fichier allocators.h.

◆ ownBaseAllocator_

template<typename BaseAllocator = CrtAllocator>
BaseAllocator* MemoryPoolAllocator< BaseAllocator >::ownBaseAllocator_
private

base allocator created by this object.

Définition à la ligne 280 du fichier allocators.h.

Référencé par MemoryPoolAllocator< BaseAllocator >::AddChunk(), et MemoryPoolAllocator< BaseAllocator >::~MemoryPoolAllocator().

◆ userBuffer_

template<typename BaseAllocator = CrtAllocator>
void* MemoryPoolAllocator< BaseAllocator >::userBuffer_
private

User supplied buffer.

Définition à la ligne 278 du fichier allocators.h.

Référencé par MemoryPoolAllocator< BaseAllocator >::Clear().


La documentation de cette classe a été générée à partir du fichier suivant :