Cuberite
A lightweight, fast and extensible game server for Minecraft
Public Member Functions | Private Member Functions | Private Attributes | List of all members
cListAllocationPool< T > Class Template Reference

Allocates memory storing unused elements in a linked list. More...

#include <AllocationPool.h>

Inheritance diagram for cListAllocationPool< T >:
Inheritance graph
[legend]
Collaboration diagram for cListAllocationPool< T >:
Collaboration graph
[legend]

Public Member Functions

virtual T * Allocate () override
 Allocates a pointer to T. More...
 
 cListAllocationPool (std::unique_ptr< typename cAllocationPool< T >::cStarvationCallbacks > a_Callbacks, size_t a_MinElementsInReserve, size_t a_MaxElementsInReserve)
 
virtual void Free (T *a_ptr) override
 Frees the pointer passed in a_ptr, invalidating it. More...
 
virtual ~cListAllocationPool () override
 
- Public Member Functions inherited from cAllocationPool< T >
bool IsEqual (const cAllocationPool &a_Other) const NOEXCEPT
 Two pools compare equal if memory allocated by one can be freed by the other. More...
 
virtual ~cAllocationPool ()
 

Private Member Functions

virtual bool DoIsEqual (const cAllocationPool< T > &a_Other) const NOEXCEPT override
 

Private Attributes

std::unique_ptr< typename cAllocationPool< T >::cStarvationCallbacksm_Callbacks
 
std::list< void * > m_FreeList
 
size_t m_MaxElementsInReserve
 Maximum free list size before returning memory to the OS. More...
 
size_t m_MinElementsInReserve
 The minimum number of elements to keep in the free list before malloc fails. More...
 

Detailed Description

template<class T>
class cListAllocationPool< T >

Allocates memory storing unused elements in a linked list.

Keeps at least NumElementsInReserve elements in the list unless malloc fails so that the program has a reserve to handle OOM.

Definition at line 63 of file AllocationPool.h.

Constructor & Destructor Documentation

template<class T>
cListAllocationPool< T >::cListAllocationPool ( std::unique_ptr< typename cAllocationPool< T >::cStarvationCallbacks a_Callbacks,
size_t  a_MinElementsInReserve,
size_t  a_MaxElementsInReserve 
)
inline

Definition at line 68 of file AllocationPool.h.

template<class T>
virtual cListAllocationPool< T >::~cListAllocationPool ( )
inlineoverridevirtual

Definition at line 86 of file AllocationPool.h.

Member Function Documentation

template<class T>
virtual T* cListAllocationPool< T >::Allocate ( )
inlineoverridevirtual

Allocates a pointer to T.

Implements cAllocationPool< T >.

Definition at line 96 of file AllocationPool.h.

template<class T>
virtual bool cListAllocationPool< T >::DoIsEqual ( const cAllocationPool< T > &  a_Other) const
inlineoverrideprivatevirtual

Implements cAllocationPool< T >.

Definition at line 179 of file AllocationPool.h.

template<class T>
virtual void cListAllocationPool< T >::Free ( T *  a_ptr)
inlineoverridevirtual

Frees the pointer passed in a_ptr, invalidating it.

Implements cAllocationPool< T >.

Definition at line 149 of file AllocationPool.h.

Member Data Documentation

template<class T>
std::unique_ptr<typename cAllocationPool<T>::cStarvationCallbacks> cListAllocationPool< T >::m_Callbacks
private

Definition at line 177 of file AllocationPool.h.

template<class T>
std::list<void *> cListAllocationPool< T >::m_FreeList
private

Definition at line 176 of file AllocationPool.h.

template<class T>
size_t cListAllocationPool< T >::m_MaxElementsInReserve
private

Maximum free list size before returning memory to the OS.

Definition at line 175 of file AllocationPool.h.

template<class T>
size_t cListAllocationPool< T >::m_MinElementsInReserve
private

The minimum number of elements to keep in the free list before malloc fails.

Definition at line 173 of file AllocationPool.h.


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