C/C++ API Reference
Loading...
Searching...
No Matches

Overview

Classes

class  pw::allocator::BestFitAllocator< BlockType >
 
class  pw::allocator::BlockAllocator< BlockType_ >
 
class  pw::allocator::BasicBucketAllocator< BlockType >
 
class  pw::allocator::BucketAllocator< BlockType, kMinInnerSize, kNumBuckets >
 
class  pw::allocator::DlAllocator< BlockType >
 
class  pw::allocator::FirstFitAllocator< BlockType >
 
struct  pw::allocator::TlsfDefaults
 
struct  pw::allocator::TlsfIndices
 Pair used to index a bucket in a two dimensional array. More...
 
class  pw::allocator::TlsfAllocator< BlockType, kMinSize, kNumShelves >
 
class  pw::allocator::WorstFitAllocator< BlockType >
 

Typedefs

template<typename OffsetType >
using pw::allocator::BestFitBlock = DetailedBlock< OffsetType, GenericFastSortedItem >
 Alias for a default block type that is compatible with FirstFitAllocator.
 
template<typename OffsetType = uintptr_t>
using pw::allocator::BucketBlock = DetailedBlock< OffsetType, UnorderedItem >
 
template<typename OffsetType >
using pw::allocator::DlBlock = DetailedBlock< OffsetType, GenericFastSortedItem >
 Alias for a default block type that is compatible with DlAllocator.
 
template<typename OffsetType >
using pw::allocator::FirstFitBlock = DetailedBlock< OffsetType, SequencedItem >
 Alias for a default block type that is compatible with FirstFitAllocator.
 
template<typename OffsetType >
using pw::allocator::TlsfBlock = DetailedBlock< OffsetType, GenericFastSortedItem >
 Alias for a default block type that is compatible with TlsfAllocator.
 
template<typename OffsetType >
using pw::allocator::WorstFitBlock = DetailedBlock< OffsetType, GenericFastSortedItem >
 Alias for a default block type that is compatible with FirstFitAllocator.
 

Functions

size_t pw::allocator::BestFitAllocator< BlockType >::DoGetMaxAllocatable () override
 
BlockResult< BlockType > pw::allocator::BestFitAllocator< BlockType >::ChooseBlock (Layout layout) override
 
void pw::allocator::BestFitAllocator< BlockType >::ReserveBlock (BlockType &block) override
 
void pw::allocator::BestFitAllocator< BlockType >::RecycleBlock (BlockType &block) override
 

Typedef Documentation

◆ BucketBlock

template<typename OffsetType = uintptr_t>
using pw::allocator::BucketBlock = typedef DetailedBlock<OffsetType, UnorderedItem>

Alias for a default block type that is compatible with BucketAllocator.

Function Documentation

◆ ChooseBlock()

template<typename BlockType >
BlockResult< BlockType > pw::allocator::BestFitAllocator< BlockType >::ChooseBlock ( Layout  layout)
overrideprivatevirtual

Selects a free block to allocate from.

This method represents the allocator-specific strategy of choosing which block should be used to satisfy allocation requests. If the returned result indicates success, block will be replaced by the chosen block.

Parameters
blockUsed to return the chosen block.
layoutSame as Allocator::Allocate.

Implements pw::allocator::BlockAllocator< BlockType_ >.

◆ DoGetMaxAllocatable()

template<typename BlockType >
size_t pw::allocator::BestFitAllocator< BlockType >::DoGetMaxAllocatable
overrideprivatevirtual

Returns the largest single allocation that can succeed, given the current state of the allocator.

The largest allocation possible at any given time is the inner size of the largest free block. This method may be expensive to call if the block allocator implementation does not track its largest block. As a result, it should primarily be used for diagnostic purposes after an allocation failure, e.g.

auto my_object = block_allocator.MakeUnique<MyObject>(my_args);
if (my_object == nullptr) {
PW_LOG("failed to allocate: needed %zu bytes, but only have %zu",
sizeof(MyObject), block_allocator.GetMaxAllocatable());
}
#define PW_LOG( level, verbosity, module, flags,...)
Definition: log.h:73

Note that this method does not consider alignment. An allocation with a large alignment requirement may fail even when a large enough block is available if that block cannot satisfy the alignment requirement.

Implements pw::allocator::BlockAllocator< BlockType_ >.

◆ RecycleBlock()

template<typename BlockType >
void pw::allocator::BestFitAllocator< BlockType >::RecycleBlock ( BlockType &  block)
overrideprivatevirtual

Indicates that a block is now free.

Does nothing by default. Derived class may overload to do additional bookkeeeping.

Parameters
blockThe block being freed.

Reimplemented from pw::allocator::BlockAllocator< BlockType_ >.

◆ ReserveBlock()

template<typename BlockType >
void pw::allocator::BestFitAllocator< BlockType >::ReserveBlock ( BlockType &  block)
overrideprivatevirtual

Indicates that a block will no longer be free.

Does nothing by default. Derived class may overload to do additional bookkeeeping.

Parameters
blockThe block being freed.

Reimplemented from pw::allocator::BlockAllocator< BlockType_ >.