C/C++ API Reference
Loading...
Searching...
No Matches
pw::allocator::internal::SortedBucketBase< Derived, BlockType > Class Template Reference

Overview

template<typename Derived, typename BlockType>
class pw::allocator::internal::SortedBucketBase< Derived, BlockType >

Container of size-sorted free blocks.

The container used to hold the free blocks is a forward list. As a result, it is able to store small free blocks with inner sizes as small as sizeof(void*). However, holding such small blocks in a sorted list requires that insertion and removal are O(n) operations. As such, this bucket type is only useful for bounded lists of free blocks, such as caches.

This CRTP-style base class requires a derived class to provide a predicate that indicates where each item should be inserted in the list.

Inheritance diagram for pw::allocator::internal::SortedBucketBase< Derived, BlockType >:
pw::allocator::internal::BucketBase< Derived, BlockType, SortedItem > pw::allocator::ForwardSortedBucket< BestFitBlock< uintptr_t > > pw::allocator::ForwardSortedBucket< TlsfBlock< uint32_t > > pw::allocator::ReverseSortedBucket< WorstFitBlock< uintptr_t > >

Protected Types

using Base = BucketBase< Derived, BlockType, SortedItem >
 

Protected Member Functions

const IntrusiveForwardList< SortedItem > & items () const
 
void DoAdd (BlockType &block)
 
BlockType * DoRemoveAny ()
 
bool DoRemove (BlockType &block)
 
BlockType * DoRemoveCompatible (Layout layout)
 

Protected Attributes

friend Base
 

Additional Inherited Members

- Public Types inherited from pw::allocator::internal::BucketBase< Derived, BlockType, SortedItem >
using BlockType = BlockType
 
using ItemType = SortedItem
 
- Public Member Functions inherited from pw::allocator::internal::BucketBase< Derived, BlockType, SortedItem >
constexpr bool empty () const
 Returns whether this buckets contains any free blocks.
 
constexpr size_t max_inner_size () const
 Returns the configured maximum inner size for blocks in this bucket.
 
constexpr void set_max_inner_size (size_t max_inner_size)
 
bool Add (BlockType &block)
 
const BlockType * FindLargest () const
 
BlockType * RemoveAny ()
 
bool Remove (BlockType &block)
 
BlockType * RemoveCompatible (Layout layout)
 
void Clear ()
 Removes all blocks from this bucket.
 
- Static Protected Member Functions inherited from pw::allocator::internal::BucketBase< Derived, BlockType, SortedItem >
static Iterator FindPrevIf (Iterator before_first, Iterator last, Predicate predicate)
 
static auto MakeCanAllocPredicate (Layout layout)
 
static bool Compare (const ItemType &item1, const ItemType &item2)
 
static constexpr BlockType * GetBlockFromIterator (Iterator iter, Iterator last)
 
static constexpr BlockType * GetBlockFromPrev (Iterator prev, Iterator last)
 
static ItemTypeGetItemFrom (BlockType &block)
 

Member Function Documentation

◆ DoAdd()

template<typename Derived , typename BlockType >
void pw::allocator::internal::SortedBucketBase< Derived, BlockType >::DoAdd ( BlockType &  block)
inlineprotected

◆ DoRemove()

template<typename Derived , typename BlockType >
bool pw::allocator::internal::SortedBucketBase< Derived, BlockType >::DoRemove ( BlockType &  block)
inlineprotected

◆ DoRemoveAny()

template<typename Derived , typename BlockType >
BlockType * pw::allocator::internal::SortedBucketBase< Derived, BlockType >::DoRemoveAny ( )
inlineprotected

◆ DoRemoveCompatible()

template<typename Derived , typename BlockType >
BlockType * pw::allocator::internal::SortedBucketBase< Derived, BlockType >::DoRemoveCompatible ( Layout  layout)
inlineprotected


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