Gobelijn API documentation  - generated for commit a0cbea7
 All Classes Namespaces Files Functions Variables Typedefs Friends Macros Pages
Pimpl::MemoryPool Class Reference

A memory pool that uses the pointer-to-implementation idiom under the hood. More...

#include <MemoryPool.h>

Collaboration diagram for Pimpl::MemoryPool:
Collaboration graph

Public Member Functions

 MemoryPool ()=delete
 
 MemoryPool (const MemoryPool &)=delete
 
 MemoryPool (MemoryPool &&)=delete
 
MemoryPooloperator= (const MemoryPool &)=delete
 
MemoryPooloperator= (MemoryPool &&)=delete
 
 MemoryPool (size_t capacity)
 Creates a memory pool that can allocate at least as many bytes as specified by the given capacity. More...
 
 ~MemoryPool ()
 Frees this memory pool's resources, if any. More...
 
template<typename T >
T * Allocate (size_t size=1)
 Allocates a region of memory that is 'size * sizeof(T)' of bytes in size. More...
 

Private Member Functions

char * AllocateMemory (size_t size)
 Allocates a region of memory that is the given number of bytes in size. More...
 

Private Attributes

std::unique_ptr< MemoryPoolImpl > m_impl
 Fortunately, we don't need a definition to create a pointer to MemoryPoolImpl, so that's exactly what we'll do. More...
 

Detailed Description

A memory pool that uses the pointer-to-implementation idiom under the hood.

This allows developers to switch MemoryPool implementation without re-compiling any other files.

Definition at line 30 of file MemoryPool.h.

Constructor & Destructor Documentation

Pimpl::MemoryPool::MemoryPool ( )
delete
Pimpl::MemoryPool::MemoryPool ( const MemoryPool )
delete
Pimpl::MemoryPool::MemoryPool ( MemoryPool &&  )
delete
Pimpl::MemoryPool::MemoryPool ( size_t  capacity)

Creates a memory pool that can allocate at least as many bytes as specified by the given capacity.

Creates a memory pool that has at least the given capacity.

Definition at line 36 of file array-impl.cpp.

Pimpl::MemoryPool::~MemoryPool ( )

Frees this memory pool's resources, if any.

Definition at line 41 of file array-impl.cpp.

References m_impl.

Member Function Documentation

MemoryPool& Pimpl::MemoryPool::operator= ( const MemoryPool )
delete
MemoryPool& Pimpl::MemoryPool::operator= ( MemoryPool &&  )
delete
template<typename T >
T* Pimpl::MemoryPool::Allocate ( size_t  size = 1)
inline

Allocates a region of memory that is 'size * sizeof(T)' of bytes in size.

It fits exactly 'size' instances of 'T'.

Definition at line 50 of file MemoryPool.h.

References AllocateMemory().

Referenced by main().

Here is the call graph for this function:

Here is the caller graph for this function:

char * Pimpl::MemoryPool::AllocateMemory ( size_t  size)
private

Allocates a region of memory that is the given number of bytes in size.

Definition at line 51 of file array-impl.cpp.

References m_impl.

Referenced by Allocate().

Here is the caller graph for this function:

Member Data Documentation

std::unique_ptr<MemoryPoolImpl> Pimpl::MemoryPool::m_impl
private

Fortunately, we don't need a definition to create a pointer to MemoryPoolImpl, so that's exactly what we'll do.

Definition at line 60 of file MemoryPool.h.

Referenced by AllocateMemory(), and ~MemoryPool().


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