Pigweed
 
Loading...
Searching...
No Matches
pw::allocator::SequencedBucket< BlockType > Class Template Reference

#include <sequenced.h>

Inheritance diagram for pw::allocator::SequencedBucket< BlockType >:
pw::allocator::internal::BucketBase< SequencedBucket< BlockType >, BlockType, SequencedItem >

Public Member Functions

constexpr size_t threshold () const
 
void set_threshold (size_t threshold)
 
- Public Member Functions inherited from pw::allocator::internal::BucketBase< SequencedBucket< BlockType >, BlockType, SequencedItem >
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)
 
BlockType * RemoveAny ()
 
bool Remove (BlockType &block)
 
BlockType * RemoveCompatible (Layout layout)
 
void Clear ()
 Removes all blocks from this bucket.
 
constexpr BlockType * GetBlockFromIterator (Iterator iter, Iterator last)
 
constexpr BlockType * GetBlockFromPrev (Iterator prev, Iterator last)
 

Additional Inherited Members

- Public Types inherited from pw::allocator::internal::BucketBase< SequencedBucket< BlockType >, BlockType, SequencedItem >
using BlockType = BlockType
 
using ItemType = SequencedItem
 
- Static Public Member Functions inherited from pw::allocator::internal::BucketBase< SequencedBucket< BlockType >, BlockType, SequencedItem >
static Iterator FindPrevIf (Iterator before_first, Iterator last, Predicate predicate)
 
static auto MakeCanAllocPredicate (Layout layout)
 
- Static Protected Member Functions inherited from pw::allocator::internal::BucketBase< SequencedBucket< BlockType >, BlockType, SequencedItem >
static ItemTypeGetItemFrom (BlockType &block)
 

Detailed Description

template<typename BlockType>
class pw::allocator::SequencedBucket< BlockType >

Container of a sequence of free blocks.

The container used to hold the blocks is a doubly-linked list. The list is sorted on the memory address of the blocks themselves. Insertion is O(n), while removal is O(1). This bucket type is useful when the order of blocks must be preserved.

Member Function Documentation

◆ set_threshold()

template<typename BlockType >
void pw::allocator::SequencedBucket< BlockType >::set_threshold ( size_t  threshold)
inline

Sets the threshold for which blocks are considered "large".

This threshold can improve performance when blocks are partitioned based on size. Iterating over the free blocks to add or remove a block will start at the beginning for block with an inner size considered "large", and the end for blocks with an inner size considered "small".


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