Arcane  4.1.12.0
Developer documentation
Loading...
Searching...
No Matches
Arcane::MultiBufferT< T > Class Template Reference

Buffer for multiple allocation. More...

#include <arcane/utils/MultiBuffer.h>

Collaboration diagram for Arcane::MultiBufferT< T >:

Public Types

typedef UniqueArray< T > BufferType

Public Member Functions

 MultiBufferT (Integer buf_size)
 MultiBufferT (const MultiBufferT< T > &ref)
 Copy constructor.
void operator= (const MultiBufferT< T > &ref)
 Copy assignment operator (forbidden).
T * allocOne ()
 Allocates a new element.
ArrayView< T > allocMany (Integer n)
 Allocates n elements.
void clear ()
Integer nbAllocatedBuffer ()
Integer bufferSize () const

Protected Member Functions

void _freeAllocatedBuffers ()

Private Member Functions

void _allocateCurrentBuffer ()

Private Attributes

Integer m_buffer_size
 Number of elements in a buffer.
Integer m_current_buffer_size
 Maximum number of elements in the current buffer.
Integer m_nb_in_buffer
 Number of elements in the current buffer.
BufferType * m_current_buffer
 Current buffer.
UniqueArray< BufferType * > m_allocated_buffers
 List of all buffers.

Detailed Description

template<class T>
class Arcane::MultiBufferT< T >

Buffer for multiple allocation.

This class manages a pre-allocated list of elements in order to limit multiple calls to allocations (new() or malloc()).

Pre-allocations are done in blocks of m_buffer_size elements

To be used by this class, a type must possess a default constructor and a copy operator. This class guarantees that the returned pointers remain valid as long as this instance exists.

The constructors and copy operators do not duplicate memory but simply retain the buffer size.

Definition at line 44 of file MultiBuffer.h.

Member Typedef Documentation

◆ BufferType

template<class T>
typedef UniqueArray<T> Arcane::MultiBufferT< T >::BufferType

Definition at line 48 of file MultiBuffer.h.

Constructor & Destructor Documentation

◆ MultiBufferT() [1/3]

template<class T>
Arcane::MultiBufferT< T >::MultiBufferT ( )
inline

Definition at line 52 of file MultiBuffer.h.

◆ MultiBufferT() [2/3]

template<class T>
Arcane::MultiBufferT< T >::MultiBufferT ( Integer buf_size)
inline

Definition at line 59 of file MultiBuffer.h.

◆ MultiBufferT() [3/3]

template<class T>
Arcane::MultiBufferT< T >::MultiBufferT ( const MultiBufferT< T > & ref)
inline

Copy constructor.

Definition at line 68 of file MultiBuffer.h.

References m_buffer_size, m_current_buffer, m_current_buffer_size, and m_nb_in_buffer.

◆ ~MultiBufferT()

template<class T>
Arcane::MultiBufferT< T >::~MultiBufferT ( )
inline

Definition at line 75 of file MultiBuffer.h.

Member Function Documentation

◆ _allocateCurrentBuffer()

template<class T>
void Arcane::MultiBufferT< T >::_allocateCurrentBuffer ( )
inlineprivate

Definition at line 155 of file MultiBuffer.h.

◆ _freeAllocatedBuffers()

template<class T>
void Arcane::MultiBufferT< T >::_freeAllocatedBuffers ( )
inlineprotected

Definition at line 139 of file MultiBuffer.h.

◆ allocMany()

template<class T>
ArrayView< T > Arcane::MultiBufferT< T >::allocMany ( Integer n)
inline

Allocates n elements.

Definition at line 106 of file MultiBuffer.h.

References m_allocated_buffers, m_current_buffer, m_current_buffer_size, and m_nb_in_buffer.

◆ allocOne()

template<class T>
T * Arcane::MultiBufferT< T >::allocOne ( )
inline

Allocates a new element.

Definition at line 94 of file MultiBuffer.h.

References m_current_buffer, m_current_buffer_size, and m_nb_in_buffer.

◆ bufferSize()

template<class T>
Integer Arcane::MultiBufferT< T >::bufferSize ( ) const
inline

Definition at line 135 of file MultiBuffer.h.

◆ clear()

template<class T>
void Arcane::MultiBufferT< T >::clear ( )
inline

Definition at line 127 of file MultiBuffer.h.

◆ nbAllocatedBuffer()

template<class T>
Integer Arcane::MultiBufferT< T >::nbAllocatedBuffer ( )
inline

Definition at line 134 of file MultiBuffer.h.

◆ operator=()

template<class T>
void Arcane::MultiBufferT< T >::operator= ( const MultiBufferT< T > & ref)
inline

Copy assignment operator (forbidden).

Definition at line 83 of file MultiBuffer.h.

References m_buffer_size.

Member Data Documentation

◆ m_allocated_buffers

template<class T>
UniqueArray<BufferType*> Arcane::MultiBufferT< T >::m_allocated_buffers
private

List of all buffers.

Definition at line 152 of file MultiBuffer.h.

Referenced by allocMany().

◆ m_buffer_size

template<class T>
Integer Arcane::MultiBufferT< T >::m_buffer_size
private

Number of elements in a buffer.

Definition at line 148 of file MultiBuffer.h.

Referenced by MultiBufferT(), and operator=().

◆ m_current_buffer

template<class T>
BufferType* Arcane::MultiBufferT< T >::m_current_buffer
private

Current buffer.

Definition at line 151 of file MultiBuffer.h.

Referenced by allocMany(), allocOne(), and MultiBufferT().

◆ m_current_buffer_size

template<class T>
Integer Arcane::MultiBufferT< T >::m_current_buffer_size
private

Maximum number of elements in the current buffer.

Definition at line 149 of file MultiBuffer.h.

Referenced by allocMany(), allocOne(), and MultiBufferT().

◆ m_nb_in_buffer

template<class T>
Integer Arcane::MultiBufferT< T >::m_nb_in_buffer
private

Number of elements in the current buffer.

Definition at line 150 of file MultiBuffer.h.

Referenced by allocMany(), allocOne(), and MultiBufferT().


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