engine
 
载入中...
搜索中...
未找到
Public 成员函数 | 所有成员列表
TAllocatorFixedSizeFreeList< AllocationSize, BlockSize > 模板类 参考

Fixed-sized allocator that uses a free list to cache allocations. 更多...

#include <AllocatorFixedSizeFreeList.h>

Public 成员函数

void * Allocate ()
 Allocates one element from the free list. 更多...
 
void Free (void *Element)
 Returns one element from the free list. 更多...
 
uint32 GetAllocatedSize () const
 Get total memory allocated. 更多...
 
void Grow (uint32 NumElements)
 Grows the free list by a specific number of elements. 更多...
 
 TAllocatorFixedSizeFreeList (uint32 InitialBlockSize=0)
 Ctor 更多...
 
 ~TAllocatorFixedSizeFreeList ()
 Destructor. 更多...
 

详细描述

template<uint32 AllocationSize, uint32 BlockSize>
class TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >

Fixed-sized allocator that uses a free list to cache allocations.

Initial allocation block can be specified in the ctor to warm the cache. Subsequent allocations are in multiples of the given blocksize.

Grow can be called at any time to warm the cache with a single block allocation. Initial allocation will want to be a reasonable guess as to how big the pool might grow. BlockSize should be small enough to cut down on allocations but not overcommit memory.

NOTE: Currently there is not way to flush the pool because it doesn't track each block's allocation status.

Not threadsafe <could be implemented using a ThreadingPolicy template parameter>.

Template params: AllocationSize - size of each allocation (must be at least as large as a pointer) BlockSize - number of allocations to reserve room for when a new block needs to be allocated.

构造及析构函数说明

◆ TAllocatorFixedSizeFreeList()

template<uint32 AllocationSize, uint32 BlockSize>
TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >::TAllocatorFixedSizeFreeList ( uint32  InitialBlockSize = 0)
inline

Ctor

参数
InitialBlockSize- number of allocations to warm the cache with

◆ ~TAllocatorFixedSizeFreeList()

template<uint32 AllocationSize, uint32 BlockSize>
TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >::~TAllocatorFixedSizeFreeList ( )
inline

Destructor.

Can't free memory, so only checks that allocations have been returned.

成员函数说明

◆ Allocate()

template<uint32 AllocationSize, uint32 BlockSize>
void * TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >::Allocate ( )
inline

Allocates one element from the free list.

Return it by calling Free.

◆ Free()

template<uint32 AllocationSize, uint32 BlockSize>
void TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >::Free ( void *  Element)
inline

Returns one element from the free list.

Must have been acquired previously by Allocate.

◆ GetAllocatedSize()

template<uint32 AllocationSize, uint32 BlockSize>
uint32 TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >::GetAllocatedSize ( ) const
inline

Get total memory allocated.

Only returns the size of allocations made directly by the allocator, not the elements themselves.

◆ Grow()

template<uint32 AllocationSize, uint32 BlockSize>
void TAllocatorFixedSizeFreeList< AllocationSize, BlockSize >::Grow ( uint32  NumElements)
inline

Grows the free list by a specific number of elements.

Does one allocation for all elements. Safe to call at any time to warm the cache with a single block allocation.


该类的文档由以下文件生成: